use of com.iwave.ext.linux.model.IScsiHost in project coprhd-controller by CoprHD.
the class LinuxSupport method checkIScsiConnectivity.
private void checkIScsiConnectivity(Set<Initiator> initiators, BlockObjectRestRep volume) {
List<ITLRestRep> exports = BlockStorageUtils.getExportsForBlockObject(volume.getId());
List<ITLRestRep> connectedExports = BlockStorageUtils.getExportsForInitiators(exports, initiators);
// Ensure we have at least one connection to the volume
Set<String> targetPorts = BlockStorageUtils.getTargetPortsForExports(connectedExports);
String sourceIqns = StringUtils.join(BlockStorageUtils.getPortNames(initiators), ", ");
String targetIqns = StringUtils.join(targetPorts, ", ");
logInfo("linux.support.check.connectivity", sourceIqns, targetIqns);
int connections = 0;
List<IScsiHost> iScsiInitiators = findIScsiIInitiators(initiators);
for (IScsiHost iScsiInitiator : iScsiInitiators) {
for (IScsiSession session : iScsiInitiator.getSessions()) {
String sourceIqn = session.getIfaceInitiatorName();
if (session.getTarget() != null) {
String targetIqn = session.getTarget().getIqn();
if (targetPorts.contains(targetIqn)) {
logInfo("linux.support.connected", sourceIqn, targetIqn);
connections++;
}
}
}
}
if (connections == 0) {
List<IScsiSession> iScsiSessions = findIScsiSessions(initiators);
for (IScsiSession session : iScsiSessions) {
String sourceIqn = session.getIfaceInitiatorName();
if (session.getTarget() != null) {
String targetIqn = session.getTarget().getIqn();
if (targetPorts.contains(targetIqn)) {
logInfo("linux.support.connected", sourceIqn, targetIqn);
connections++;
}
}
}
}
if (connections == 0) {
Object[] detailArgs = new Object[] { volume.getId(), buildInitiatorsString(initiators) };
Object[] messageArgs = new Object[] { sourceIqns, targetIqns };
ExecutionUtils.fail("failTask.LinuxSupport.iqnConnectivity", detailArgs, messageArgs);
}
}
use of com.iwave.ext.linux.model.IScsiHost in project coprhd-controller by CoprHD.
the class FindIScsiInitiators method executeTask.
@Override
public List<IScsiHost> executeTask() throws Exception {
List<IScsiHost> hosts = executeCommand(new ListIScsiHostsCommand(), SHORT_TIMEOUT);
Iterator<IScsiHost> iter = hosts.iterator();
while (iter.hasNext()) {
IScsiHost host = iter.next();
if (!isMatch(host)) {
iter.remove();
}
}
return hosts;
}
use of com.iwave.ext.linux.model.IScsiHost in project coprhd-controller by CoprHD.
the class IScsiHostParser method parseHost.
public IScsiHost parseHost(String text) {
if (StringUtils.isBlank(text)) {
return null;
}
Map<String, String> properties = parser.parseProperties(text, ':');
IScsiHost host = new IScsiHost();
host.setHostId(NumberUtils.toInt(properties.get(HOST_NUMBER)));
host.setState(properties.get(STATE));
host.setTransport(properties.get(TRANSPORT));
host.setInitiatorName(properties.get(INITIATOR_NAME));
host.setIpAddress(properties.get(IP_ADDRESS));
host.setHwAddress(properties.get(HW_ADDRESS));
host.setNetdev(properties.get(NETDEV));
host.setSessions(sessionParser.parseSessions(text));
return host;
}
Aggregations