Search in sources :

Example 6 with NetworkDeviceControllerException

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

the class BrocadeNetworkSystemDevice method updateZones.

@Override
public BiosCommandResult updateZones(NetworkSystem networkSystem, List<ZoneUpdate> zoneUpdates, String fabricId, String fabricWwn, boolean activateZoneset) throws NetworkDeviceControllerException {
    BiosCommandResult cmdResults = null;
    try {
        WBEMClient client = getNetworkDeviceClient(networkSystem);
        validateFabric(networkSystem, fabricWwn, fabricId);
        Map<String, String> results = updateZonesStrategy(client, zoneUpdates, fabricId, fabricWwn, activateZoneset);
        cmdResults = getBiosCommandResult(results);
        _log.info("Update zone results {}", toMessage(results));
    } catch (NetworkDeviceControllerException ex) {
        _log.error("Cannot update zones: " + ex.getLocalizedMessage());
        throw ex;
    }
    return cmdResults;
}
Also used : NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) WBEMClient(javax.wbem.client.WBEMClient)

Example 7 with NetworkDeviceControllerException

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

the class MDSDialog method showIvrVsanTopology.

/**
 * Get ivr vsan topology of the switch
 *
 * @return
 * @throws NetworkDeviceControllerException
 */
public List<IvrVsanConfiguration> showIvrVsanTopology() throws NetworkDeviceControllerException {
    List<IvrVsanConfiguration> ivrVsans = new ArrayList<IvrVsanConfiguration>();
    SSHPrompt[] prompts = { SSHPrompt.POUND, SSHPrompt.GREATER_THAN, SSHPrompt.MDS_CONFIG, SSHPrompt.MDS_CONFIG_IVR_ZONE, SSHPrompt.MDS_CONFIG_IVR_ZONESET };
    StringBuilder buf = new StringBuilder();
    sendWaitFor(MDSDialogProperties.getString("MDSDialog.ivr.vsan.topology.cmd"), defaultTimeout, prompts, buf);
    String[] lines = getLines(buf);
    String[] regex = { MDSDialogProperties.getString("MDSDialog.ivr.showTopology.wwn.match") };
    String[] groups = new String[10];
    for (String line : lines) {
        int index = match(line, regex, groups);
        switch(index) {
            case 0:
                IvrVsanConfiguration ivrVsan = new IvrVsanConfiguration();
                ivrVsan.setSwitchWwn(groups[0] + groups[2]);
                // local switch is indicated by present of * character
                ivrVsan.setLocalSwitch("*".equalsIgnoreCase(groups[3]));
                try {
                    // get the first vsan in the line
                    int vsanId = Integer.valueOf(groups[4]);
                    // and get all ivr vsans via StringSplit
                    if (vsanId > 0) {
                        String vsansText = line.substring(line.indexOf(groups[4], line.indexOf(ivrVsan.getSwitchWwn()) + ivrVsan.getSwitchWwn().length()));
                        String[] vsans = vsansText.split(",");
                        for (String vsan : vsans) {
                            // get vsan range
                            if (vsan.indexOf('-') > 0) {
                                String[] range = vsan.split("-");
                                ivrVsan.getVsansRanges().add(new IntRange(Integer.valueOf(range[0].trim()), Integer.valueOf(range[1].trim())));
                            } else {
                                ivrVsan.getVsans().add(Integer.valueOf(vsan.trim()));
                            }
                        }
                    }
                } catch (Exception e) {
                // not ivr vsan
                }
                ivrVsans.add(ivrVsan);
                break;
        }
    }
    return ivrVsans;
}
Also used : ArrayList(java.util.ArrayList) IntRange(org.apache.commons.lang.math.IntRange) SSHPrompt(com.emc.storageos.networkcontroller.SSHPrompt) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)

Example 8 with NetworkDeviceControllerException

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

the class MDSDialog method ivrZonesetMember.

/**
 * member {ivrZoneName}
 *
 * @param pwwn
 * @param vsanId
 * @throws NetworkDeviceControllerException
 */
public void ivrZonesetMember(String ivrZonename, boolean isRemove) throws NetworkDeviceControllerException {
    _log.info(MessageFormat.format("Host: {0}, Port: {1} - Add or remove ivrZonesetMember: {2} - Remove {3}", new Object[] { getSession().getSession().getHost(), getSession().getSession().getPort(), ivrZonename, isRemove }));
    SSHPrompt[] prompts = { SSHPrompt.MDS_CONFIG_IVR_ZONESET };
    if (!inConfigMode) {
        throw NetworkDeviceControllerException.exceptions.mdsDeviceNotInConfigMode();
    }
    if (!Arrays.asList(prompts).contains(lastPrompt)) {
        String message = Arrays.asList(prompts).toString();
        throw NetworkDeviceControllerException.exceptions.mdsUnexpectedLastPrompt(lastPrompt.toString(), message);
    }
    // no
    String noString = isRemove ? MDSDialogProperties.getString("MDSDialog.zoneNameVsan.no.cmd") : "";
    StringBuilder buf = new StringBuilder();
    // =member
    String payload = MessageFormat.format(noString + MDSDialogProperties.getString("MDSDialog.ivr.zonesetMember.cmd"), ivrZonename);
    // {zonename}
    boolean retryNeeded = true;
    for (int retryCount = 0; retryCount < sessionLockRetryMax && retryNeeded; retryCount++) {
        lastPrompt = sendWaitFor(payload, defaultTimeout, prompts, buf);
        String[] lines = getLines(buf);
        for (String line : lines) {
            // throw exception only when trying to get into config mode, but not found
            if (line.indexOf(MDSDialogProperties.getString("MDSDialog.ivr.zone.not.found")) >= 0 && !isRemove) {
                throw new NetworkDeviceControllerException(line + ": " + ivrZonename);
            }
        }
        retryNeeded = checkForEnhancedZoneSession(lines, retryCount);
    }
}
Also used : NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException) SSHPrompt(com.emc.storageos.networkcontroller.SSHPrompt) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint)

Example 9 with NetworkDeviceControllerException

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

the class MdsNetworkSystemDevice method removeZones.

@Override
public BiosCommandResult removeZones(NetworkSystem network, List<Zone> zones, String fabricId, String fabricWwn, boolean activateZones) throws NetworkDeviceControllerException {
    BiosCommandResult result = null;
    MDSDialog dialog = null;
    Map<String, String> removedZoneNames = new HashMap<String, String>();
    try {
        dialog = setUpDialog(network);
        List<IvrZone> removingIvrZones = new ArrayList<IvrZone>();
        List<Zone> removingZones = new ArrayList<Zone>();
        for (Zone zone : zones) {
            IvrZone routedZone = getRoutedZone(dialog, zone, network);
            // as normal zone
            if (routedZone != null) {
                removingIvrZones.add(routedZone);
            } else {
                removingZones.add(zone);
            }
        }
        // Throw artificial exception here to simulate FOD for MDS same as creating alias
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_057);
        if (!removingZones.isEmpty()) {
            Integer vsanId = checkVsanFabric(dialog, fabricId, fabricWwn);
            removedZoneNames.putAll(removeZonesStrategy(dialog, removingZones, vsanId, activateZones));
        }
        if (!removingIvrZones.isEmpty()) {
            removedZoneNames.putAll(removeIvrZonesStrategy(dialog, removingIvrZones));
        }
        _log.info("Remove VSAN zone results: " + toMessage(removedZoneNames));
        result = getBiosCommandResult(removedZoneNames);
    } catch (Exception ex) {
        _log.error("Cannot remove 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 10 with NetworkDeviceControllerException

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

the class MdsNetworkSystemDevice method activateZones.

@Override
public BiosCommandResult activateZones(NetworkSystem network, String fabricId, String fabricWwn) throws NetworkDeviceControllerException {
    BiosCommandResult result = null;
    MDSDialog dialog = null;
    try {
        dialog = setUpDialog(network);
        Integer vsanId = checkVsanFabric(dialog, fabricId, fabricWwn);
        String activatedZonesetName = activateZonesStrategy(dialog, vsanId);
        String msg = "";
        if (activatedZonesetName == null) {
            msg = "Vsan: " + fabricId + ": No zoneset was activated";
        } else {
            msg = "Vsan: " + fabricId + ": Successfully activated zoneset: " + activatedZonesetName;
        }
        _log.info(msg);
        result = BiosCommandResult.createSuccessfulResult();
    } catch (NetworkDeviceControllerException ex) {
        _log.error("Cannot activate zoneset: " + (ex.getCause() != null ? ex.getCause().getMessage() : ex.getLocalizedMessage()));
        throw ex;
    } finally {
        disconnect(dialog);
    }
    return result;
}
Also used : NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult)

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