Search in sources :

Example 31 with SSHPrompt

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

the class MDSDialog method showFlogiDatabase.

/**
 * Shows the FLOGI database, which are the local logins to this switch.
 * This method is not currently used.
 *
 * @throws NetworkDeviceControllerException
 */
public void showFlogiDatabase() throws NetworkDeviceControllerException {
    SSHPrompt[] prompts = { SSHPrompt.POUND, SSHPrompt.GREATER_THAN };
    StringBuilder buf = new StringBuilder();
    // show flogi
    SSHPrompt prompt = sendWaitFor(MDSDialogProperties.getString("MDSDialog.showFlogiDatabase.cmd"), 60000, prompts, buf);
    // database\n
    String[] lines = getLines(buf);
    boolean sawHdr = false;
    String[] regex = { // INTERFACE\\s+VSAN\\s+FCID\\s+PORT
    MDSDialogProperties.getString("MDSDialog.showFlogiDatabase.INTERFACEVSANFCID.match"), // (fc\\S+)\\s+(\\d+)\\s+(\\S+)\\s+([0-9a-fA-F:]+)\\s+([0-9a-fA-F:]+)\\s*
    MDSDialogProperties.getString("MDSDialog.showFlogiDatabase.interfacename.match"), // Total number of flogi.*
    MDSDialogProperties.getString("MDSDialog.showFlogiDatabase.Totalflogi.match") };
    String[] groups = new String[10];
    for (String line : lines) {
        int index = match(line, regex, groups);
        switch(index) {
            case 0:
                sawHdr = true;
                break;
            case 1:
                _log.info(groups[0] + " " + groups[1] + " " + groups[2] + " " + groups[3] + " " + groups[4]);
                break;
            case 2:
                sawHdr = false;
                break;
        }
    }
}
Also used : SSHPrompt(com.emc.storageos.networkcontroller.SSHPrompt) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint)

Example 32 with SSHPrompt

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

the class MDSDialog method zoneNameVsan.

/**
 * zone name {zoneName} vsan {vsanId}
 * no zone name {zoneName} vsan {vsanId}
 *
 * @param zoneName
 * @param vsanId
 * @param no -- makes no version of command
 * @throws NetworkDeviceControllerException
 */
public void zoneNameVsan(String zoneName, Integer vsanId, boolean no) throws NetworkDeviceControllerException {
    if (!inConfigMode) {
        throw NetworkDeviceControllerException.exceptions.mdsDeviceNotInConfigMode();
    }
    if (lastPrompt != SSHPrompt.MDS_CONFIG) {
        throw NetworkDeviceControllerException.exceptions.mdsUnexpectedLastPrompt(lastPrompt.toString(), SSHPrompt.MDS_CONFIG.toString());
    }
    // no
    String noString = no ? MDSDialogProperties.getString("MDSDialog.zoneNameVsan.no.cmd") : "";
    SSHPrompt[] prompts = { SSHPrompt.MDS_CONFIG_ZONE, SSHPrompt.MDS_CONFIG };
    SSHPrompt[] noPrompts = { SSHPrompt.MDS_CONFIG };
    StringBuilder buf = new StringBuilder();
    boolean retryNeeded = true;
    for (int retryCount = 0; retryCount < sessionLockRetryMax && retryNeeded; retryCount++) {
        String payload = MessageFormat.format(MDSDialogProperties.getString("MDSDialog.zoneNameVsan.cmd"), zoneName, vsanId.toString(), // {2}zone name {0} vsan {1}\n
        noString);
        lastPrompt = sendWaitFor(payload, defaultTimeout, (no ? noPrompts : prompts), buf);
        String[] lines = getLines(buf);
        retryNeeded = checkForEnhancedZoneSession(lines, retryCount);
    }
    if ((no == false) && (lastPrompt != SSHPrompt.MDS_CONFIG_ZONE)) {
        throw NetworkDeviceControllerException.exceptions.mdsUnexpectedLastPrompt(lastPrompt.toString(), SSHPrompt.MDS_CONFIG_ZONE.toString());
    }
}
Also used : SSHPrompt(com.emc.storageos.networkcontroller.SSHPrompt) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint)

Example 33 with SSHPrompt

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

the class MDSDialog method zonesetNameVsan.

/**
 * (no) zoneset name {zonesetName} vsan {vsanId}
 *
 * @param zonesetName
 * @param vsanId
 * @param no - true for removing zoneset, false otherwise
 * @throws NetworkDeviceControllerException
 */
public void zonesetNameVsan(String zonesetName, Integer vsanId, boolean no) throws NetworkDeviceControllerException {
    if (!inConfigMode) {
        throw NetworkDeviceControllerException.exceptions.mdsDeviceNotInConfigMode();
    }
    if (lastPrompt != SSHPrompt.MDS_CONFIG) {
        throw NetworkDeviceControllerException.exceptions.mdsUnexpectedLastPrompt(lastPrompt.toString(), SSHPrompt.MDS_CONFIG.toString());
    }
    // no
    String noString = no ? MDSDialogProperties.getString("MDSDialog.zonesetNameVsan.no.cmd") : "";
    SSHPrompt[] prompts = { SSHPrompt.MDS_CONFIG_ZONESET, SSHPrompt.MDS_CONFIG };
    StringBuilder buf = new StringBuilder();
    boolean retryNeeded = true;
    for (int retryCount = 0; retryCount < sessionLockRetryMax && retryNeeded; retryCount++) {
        String payload = MessageFormat.format(MDSDialogProperties.getString("MDSDialog.zonesetNameVsan.cmd"), zonesetName, vsanId.toString(), // zoneset name {0} vsan {1}\n
        noString);
        lastPrompt = sendWaitFor(payload, defaultTimeout, prompts, buf);
        String[] lines = getLines(buf);
        retryNeeded = checkForEnhancedZoneSession(lines, retryCount);
    }
    if (no == false && lastPrompt != SSHPrompt.MDS_CONFIG_ZONESET) {
        throw NetworkDeviceControllerException.exceptions.mdsUnexpectedLastPrompt(lastPrompt.toString(), SSHPrompt.MDS_CONFIG_ZONESET.toString());
    }
}
Also used : SSHPrompt(com.emc.storageos.networkcontroller.SSHPrompt) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint)

Aggregations

SSHPrompt (com.emc.storageos.networkcontroller.SSHPrompt)33 FCEndpoint (com.emc.storageos.db.client.model.FCEndpoint)31 NetworkDeviceControllerException (com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)1 Set (java.util.Set)1 IntRange (org.apache.commons.lang.math.IntRange)1