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;
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations