Search in sources :

Example 11 with NetworkDeviceControllerException

use of com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException in project coprhd-controller by CoprHD.

the class MdsNetworkSystemDevice method addAliases.

@Override
public BiosCommandResult addAliases(NetworkSystem network, List<ZoneWwnAlias> addingAliases, String fabricId, String fabricWwn) throws NetworkDeviceControllerException {
    BiosCommandResult result = null;
    MDSDialog dialog = null;
    Map<String, String> addedAliasesName = new HashMap<String, String>();
    try {
        dialog = setUpDialog(network);
        if (!addingAliases.isEmpty()) {
            addedAliasesName.putAll(addAliasesStrategy(dialog, addingAliases));
        }
        String msg = "Successfully added aliases: " + addedAliasesName.toString();
        if (!hasResult(addedAliasesName, SUCCESS)) {
            msg = "Network System: " + network.getLabel() + ": No aliases were added";
        }
        _log.info(msg);
        result = getBiosCommandResult(addedAliasesName);
    } catch (Exception ex) {
        _log.error("Cannot add aliases: " + (ex.getCause() != null ? ex.getCause().getMessage() : ex.getLocalizedMessage()));
        throw ex;
    } finally {
        disconnect(dialog);
    }
    return result;
}
Also used : HashMap(java.util.HashMap) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)

Example 12 with NetworkDeviceControllerException

use of com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException in project coprhd-controller by CoprHD.

the class MdsNetworkSystemDevice method determineRoutedNetworks.

/*
     * (non-Javadoc)
     * @see com.emc.storageos.networkcontroller.impl.NetworkSystemDevice#determineRoutedNetworks(com.emc.storageos.db.client.model.NetworkSystem)
     */
@Override
public void determineRoutedNetworks(NetworkSystem networkSystem) throws NetworkDeviceControllerException {
    MDSDialog dialog = null;
    /* Example output "show ivr vsan-topology"
		 * 	AFID  SWITCH WWN                 Active   Cfg. VSANS
		 * 	-----------------------------------------------------------
		 * 	1  20:00:00:0d:ec:dc:86:40 *   yes      no  1,3,11,99,200
		 * 	1  20:00:00:2a:6a:33:13:10     yes      no  1-3,10,78,99,200
		 */
    // 1. Build a map of switchWWN to NetworkSystem for all the discovered NetworkSystems
    Map<String, NetworkSystem> switchWWNToNetworkSystemMap = new HashMap<String, NetworkSystem>();
    for (URI discoveredNetworkSystemUri : NetworkUtil.getDiscoveredNetworkSystems(_dbClient)) {
        NetworkSystem discoveredNetworkSystem = _dbClient.queryObject(NetworkSystem.class, discoveredNetworkSystemUri);
        try {
            if (discoveredNetworkSystem.getSystemType().equalsIgnoreCase(NetworkSystem.Type.mds.toString())) {
                dialog = setUpDialog(discoveredNetworkSystem);
                String switchWWN = dialog.showSwitchWwn();
                switchWWNToNetworkSystemMap.put(switchWWN, discoveredNetworkSystem);
                _log.info(String.format("NetworkSystem : %s - WWN : %s", switchWWNToNetworkSystemMap.get(switchWWN).getLabel(), switchWWN));
            }
        } catch (Exception e) {
            _log.info(String.format("Couldnt fetch the switch WWN information for %s, ignoring it", discoveredNetworkSystem.getLabel()));
        } finally {
            disconnect(dialog);
        }
    }
    // Build a map of Switch WWN to their VSANs from the topology map
    try {
        dialog = setUpDialog(networkSystem);
        String currentNetworkSytemWWN = dialog.showSwitchWwn();
        Map<String, Set<Integer>> switchWWNToVsans = new HashMap<>();
        List<IvrVsanConfiguration> ivrVsansList = dialog.showIvrVsanTopology();
        for (IvrVsanConfiguration ivrVsan : ivrVsansList) {
            Set<Integer> vsans = new HashSet<Integer>();
            vsans.addAll(ivrVsan.getVsans());
            for (IntRange ivrVsanRange : ivrVsan.getVsansRanges()) {
                for (int range = ivrVsanRange.getMinimumInteger(); range <= ivrVsanRange.getMaximumInteger(); range++) {
                    vsans.add(range);
                }
            }
            switchWWNToVsans.put(ivrVsan.getSwitchWwn(), vsans);
        }
        // 3. Check to make sure that the current Network system (that is being discovered) is in the ivr vsan-topology map.
        if (!switchWWNToVsans.containsKey(currentNetworkSytemWWN)) {
            _log.info(String.format("Currently discovered NetworkSystem with WWN %s is not part of the ivr vsan-topology, returning.", currentNetworkSytemWWN));
            return;
        }
        // 4. Loop through all the switch WWNs from the topology map and check if they are discovered.
        // If yes, then all the networks of that network-system are routable to all the other networks from other discovered switches that are also in the vsan-topology map.
        // Since this map is constructed from the output of "show ivr vsan-topology", the switch WWNs listed in that output are
        // all routable to each others for the networks that belong to them.
        // NOTE: The assumption here is that there exists a transit VSAN between the switches that are on the IVR path. ViPR will not check for existence of transit
        // networks, but it is required for inter VSAN routing in IVR configurations.
        List<Network> routedNetworks = new ArrayList<Network>();
        for (Entry<String, Set<Integer>> switchWWNToVsan : switchWWNToVsans.entrySet()) {
            String switchKey = switchWWNToVsan.getKey();
            Set<Integer> vsanValues = switchWWNToVsan.getValue();
            if (switchWWNToNetworkSystemMap.containsKey(switchKey)) {
                NetworkSystem ns = switchWWNToNetworkSystemMap.get(switchKey);
                URIQueryResultList networkSystemNetworkUriList = new URIQueryResultList();
                // Fetch all the networks of this networkSystem
                _dbClient.queryByConstraint(ContainmentConstraint.Factory.getNetworkSystemNetworkConstraint(ns.getId()), networkSystemNetworkUriList);
                for (URI networkSystemNetworkUri : networkSystemNetworkUriList) {
                    Network networkSystemNetwork = _dbClient.queryObject(Network.class, networkSystemNetworkUri);
                    if (vsanValues.contains(Integer.parseInt(networkSystemNetwork.getNativeId())) && !routedNetworks.contains(networkSystemNetwork)) {
                        if (!routedNetworks.contains(networkSystemNetwork)) {
                            _log.info("Routable Network: " + networkSystemNetwork.getLabel() + " from  Switch : " + ns.getLabel());
                            routedNetworks.add(networkSystemNetwork);
                        } else {
                            _log.info(String.format("Routed network %s already included in the list", networkSystemNetwork.getLabel()));
                        }
                    }
                }
            }
        }
        // Again, transit VSANs are required for routing to happen, but ViPR will not check for existence of transit VSANs.
        for (Network network1 : routedNetworks) {
            network1.setRoutedNetworks(new StringSet());
            for (Network network2 : routedNetworks) {
                if (network1.getNativeGuid().toString().equalsIgnoreCase(network2.getNativeGuid().toString())) {
                    _log.info(String.format("%s is same as %s no routed network update required", network1.getLabel(), network2.getLabel()));
                    continue;
                }
                _log.info(String.format("%s can route to %s", network1.getLabel().toString(), network2.getLabel().toString()));
                network1.getRoutedNetworks().add(network2.getId().toString());
            }
        }
        _log.debug("Calling dbUpdate for : " + routedNetworks.size() + " networks");
        for (Network rn : routedNetworks) {
            _log.info(rn.toString());
        }
        _dbClient.updateObject(routedNetworks);
    } catch (Exception ex) {
        _log.error("Cannot determine routable networks for networks on  " + networkSystem.getLabel() + " : " + ex.getLocalizedMessage());
        throw ex;
    } finally {
        disconnect(dialog);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) StringSet(com.emc.storageos.db.client.model.StringSet) HashMap(java.util.HashMap) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) IntRange(org.apache.commons.lang.math.IntRange) ArrayList(java.util.ArrayList) URI(java.net.URI) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Network(com.emc.storageos.db.client.model.Network) StringSet(com.emc.storageos.db.client.model.StringSet) HashSet(java.util.HashSet)

Example 13 with NetworkDeviceControllerException

use of com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException in project coprhd-controller by CoprHD.

the class MdsNetworkSystemDevice method updateAliases.

@Override
public BiosCommandResult updateAliases(NetworkSystem network, List<ZoneWwnAliasUpdate> updatingAliases, String fabricId, String fabricWwn) throws NetworkDeviceControllerException {
    BiosCommandResult result = null;
    MDSDialog dialog = null;
    Map<String, String> updatedAliasesName = new HashMap<String, String>();
    try {
        dialog = setUpDialog(network);
        if (!updatingAliases.isEmpty()) {
            updatedAliasesName.putAll(updateAliasesStrategy(dialog, updatingAliases));
        }
        String msg = "Successfully updated aliases: " + updatedAliasesName.toString();
        if (!hasResult(updatedAliasesName, SUCCESS)) {
            msg = "Network System: " + network.getLabel() + ": No aliases were updated";
        }
        _log.info(msg);
        result = getBiosCommandResult(updatedAliasesName);
    } catch (Exception ex) {
        _log.error("Cannot updated aliases: " + (ex.getCause() != null ? ex.getCause().getMessage() : ex.getLocalizedMessage()));
        throw ex;
    } finally {
        disconnect(dialog);
    }
    return result;
}
Also used : HashMap(java.util.HashMap) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)

Example 14 with NetworkDeviceControllerException

use of com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException in project coprhd-controller by CoprHD.

the class MdsNetworkSystemDevice method addZones.

@Override
public BiosCommandResult addZones(NetworkSystem networkSystem, List<Zone> zones, String fabricId, String fabricWwn, boolean activateZones) throws NetworkDeviceControllerException {
    BiosCommandResult result = null;
    MDSDialog dialog = null;
    Map<String, String> addedZoneNames = new HashMap<String, String>();
    try {
        dialog = setUpDialog(networkSystem);
        List<IvrZone> addingIvrZones = new ArrayList<IvrZone>();
        List<Zone> addingZones = new ArrayList<Zone>();
        for (Zone zone : zones) {
            IvrZone routedZone = getRoutedZone(dialog, zone, networkSystem);
            // as normal zone
            if (routedZone != null) {
                addingIvrZones.add(routedZone);
            } else {
                addingZones.add(zone);
            }
        }
        if (!addingZones.isEmpty()) {
            Integer vsanId = checkVsanFabric(dialog, fabricId, fabricWwn);
            addedZoneNames.putAll(addZonesStrategy(dialog, addingZones, vsanId, activateZones));
        }
        if (!addingIvrZones.isEmpty()) {
            addedZoneNames.putAll(addIvrZonesStrategy(dialog, addingIvrZones));
        }
        _log.info("Add SAN zones results: " + toMessage(addedZoneNames));
        String msg = "Vsan: " + fabricId + ": Successfully added zones: " + addedZoneNames.toString();
        if (addedZoneNames.size() == 0) {
            msg = "Vsan: " + fabricId + ": No zones were added";
        }
        _log.info(msg);
        result = getBiosCommandResult(addedZoneNames);
    } catch (Exception ex) {
        _log.error("Cannot add zones: " + (ex.getCause() != null ? ex.getCause().getMessage() : ex.getLocalizedMessage()));
        throw ex;
    } finally {
        disconnect(dialog);
    }
    return result;
}
Also used : HashMap(java.util.HashMap) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ArrayList(java.util.ArrayList) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)

Example 15 with NetworkDeviceControllerException

use of com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException in project coprhd-controller by CoprHD.

the class MdsNetworkSystemDevice method setUpDialog.

/**
 * Sets up a session. Gets session parameters from the NetworkSystem.
 *
 * @param networkSystem NetworkSystem
 * @return MDSDialog representing the session
 * @throws NetworkDeviceControllerException
 */
private MDSDialog setUpDialog(NetworkSystem networkSystem) throws NetworkDeviceControllerException {
    try {
        SSHSession session = new SSHSession();
        session.connect(networkSystem.getIpAddress(), networkSystem.getPortNumber(), networkSystem.getUsername(), networkSystem.getPassword());
        MDSDialog dialog = new MDSDialog(session, getDefaultTimeout());
        dialog.initialize();
        return dialog;
    } catch (Exception ex) {
        String exMsg = ex.getLocalizedMessage();
        if (exMsg.equals("Auth fail")) {
            exMsg = "Authorization Failed";
        }
        if (exMsg.equals("timeout: socket is not established")) {
            exMsg = "Connection Failed";
        }
        String msg = MessageFormat.format("Could not connect to device {0}: {1}", networkSystem.getLabel(), exMsg);
        _log.error(msg);
        throw NetworkDeviceControllerException.exceptions.setUpDialogFailed(networkSystem.getLabel(), exMsg, ex);
    }
}
Also used : SSHSession(com.emc.storageos.networkcontroller.SSHSession) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)

Aggregations

NetworkDeviceControllerException (com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)26 HashMap (java.util.HashMap)12 FCEndpoint (com.emc.storageos.db.client.model.FCEndpoint)10 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)10 SSHPrompt (com.emc.storageos.networkcontroller.SSHPrompt)7 ControllerException (com.emc.storageos.volumecontroller.ControllerException)7 ArrayList (java.util.ArrayList)7 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 CIMInstance (javax.cim.CIMInstance)5 CIMObjectPath (javax.cim.CIMObjectPath)5 WBEMException (javax.wbem.WBEMException)5 WBEMClient (javax.wbem.client.WBEMClient)5 Zone (com.emc.storageos.networkcontroller.impl.mds.Zone)3 NetworkLite (com.emc.storageos.util.NetworkLite)2 List (java.util.List)2 IntRange (org.apache.commons.lang.math.IntRange)2 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 Network (com.emc.storageos.db.client.model.Network)1 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)1