use of com.iwave.ext.linux.model.IScsiTarget in project coprhd-controller by CoprHD.
the class IScsiTargetParser method parseTargetBlock.
private List<IScsiTarget> parseTargetBlock(String text) {
String iqn = parser.findMatch(TARGET, text);
if (StringUtils.isNotBlank(iqn)) {
List<IScsiTarget> targets = Lists.newArrayList();
for (String textBlock : portalParser.parseTextBlocks(text)) {
String portal = parser.findMatch(PORTAL, textBlock);
String ifaceName = parser.findMatch(IFACE_NAME, textBlock);
targets.add(new IScsiTarget(StringUtils.trim(iqn), StringUtils.trim(portal), StringUtils.trim(ifaceName)));
}
return targets;
} else {
return Collections.emptyList();
}
}
use of com.iwave.ext.linux.model.IScsiTarget in project coprhd-controller by CoprHD.
the class DiscoverIScsiTargetsParser method parseTargets.
public List<IScsiTarget> parseTargets(String text) {
List<IScsiTarget> targets = Lists.newArrayList();
for (String line : StringUtils.split(text, "\n")) {
Matcher m = ISCSI_TARGETS.matcher(line);
if (m.find()) {
String portal = m.group(1);
String iqn = m.group(2);
if (isValidPortal(portal)) {
targets.add(new IScsiTarget(iqn, portal, null));
}
}
}
return targets;
}
use of com.iwave.ext.linux.model.IScsiTarget in project coprhd-controller by CoprHD.
the class IScsiSessionParser method parseSession.
public IScsiSession parseSession(String text) {
if (StringUtils.isBlank(text)) {
return null;
}
Map<String, String> properties = parser.parseProperties(text, ':');
IScsiSession session = new IScsiSession();
IScsiTarget target = new IScsiTarget();
String targetValue = null;
if (properties.get(TARGET) != null && properties.get(TARGET).contains(" ")) {
targetValue = StringUtils.substring(properties.get(TARGET), 0, properties.get(TARGET).indexOf(" "));
} else {
targetValue = properties.get(TARGET);
}
target.setIqn(targetValue);
target.setPortal(properties.get(CURRENT_PORTAL));
target.setIfaceName(properties.get(IFACE_NAME));
session.setTarget(target);
session.setPersistentPortal(properties.get(PERSISTENT_PORTAL));
session.setIfaceTransport(properties.get(IFACE_TRANSPORT));
session.setIfaceInitiatorName(properties.get(IFACE_INITIATOR_NAME));
session.setIfaceIPAddress(properties.get(IFACE_IP_ADDRESS));
session.setIfaceHWAddress(properties.get(IFACE_HW_ADDRESS));
session.setIfaceNetdev(properties.get(IFACE_NETDEV));
session.setSessionID(properties.get(SESSION_ID));
session.setConnectionState(properties.get(CONNECTION_STATE));
session.setSessionState(properties.get(SESSION_STATE));
return session;
}
Aggregations