use of com.emc.storageos.vnxe.models.VNXeIscsiPortal in project coprhd-controller by CoprHD.
the class VNXeCommunicationInterface method discoverIscsiPorts.
/**
* Discover iscsiPorts
*
* @param system
* @param client
* @param spIdMap
* storage processors VNXeId and ViPR URI map
* @return
* @throws VNXeException
*/
private HashMap<String, List<StoragePort>> discoverIscsiPorts(StorageSystem system, VNXeApiClient client, Map<String, URI> spIdMap) throws VNXeException {
HashMap<String, List<StoragePort>> storagePorts = new HashMap<String, List<StoragePort>>();
List<StoragePort> newStoragePorts = new ArrayList<StoragePort>();
List<StoragePort> existingStoragePorts = new ArrayList<StoragePort>();
_logger.info("Start iSCSI storage port discovery for storage system {}", system.getId());
// Retrieve the list of iscsi ports
List<VNXeIscsiNode> ports = client.getAllIscsiPorts();
if (ports == null || ports.isEmpty()) {
_logger.info("No iSCSI ports found for the system: {} ", system.getId());
return storagePorts;
}
_logger.info("Number iSCSI ports found: {}", ports.size());
// Create the list of storage ports.
for (VNXeIscsiNode node : ports) {
StoragePort port = null;
VNXeEthernetPort eport = node.getEthernetPort();
if (eport == null) {
_logger.info("No ethernet port found for the iscsi node: {}", node.getId());
continue;
}
VNXeBase spId = eport.getStorageProcessorId();
if (spId == null) {
_logger.info("No storage processor info for the iscsi node: {}", node.getId());
continue;
}
String spIdStr = spId.getId();
URI haDomainUri = spIdMap.get(spIdStr);
if (haDomainUri == null) {
_logger.info("The sp {} has not been discovered.", spIdStr);
continue;
}
// Check if storage port was already discovered
String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, node.getName(), NativeGUIDGenerator.PORT);
URIQueryResultList results = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
if (results.iterator().hasNext()) {
_logger.info("cross verifying for duplicate port");
StoragePort tmpPort = _dbClient.queryObject(StoragePort.class, results.iterator().next());
_logger.info(String.format("Actual StorageDevice %s : PortGroup found for port %s - Actual PortGroup %s", system.getId(), tmpPort.getPortNetworkId(), tmpPort.getPortGroup()));
if (tmpPort.getStorageDevice().equals(system.getId()) && tmpPort.getPortGroup().equals(spIdStr)) {
port = tmpPort;
_logger.info("found duplicate iscsi port {}", node.getName());
}
}
// If iscsi port was not previously discovered, add new storage port
if (port == null) {
port = new StoragePort();
port.setId(URIUtil.createId(StoragePort.class));
port.setLabel(portNativeGuid);
port.setTransportType("IP");
port.setNativeGuid(portNativeGuid);
port.setStorageDevice(system.getId());
port.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
port.setPortName(eport.getId());
port.setPortNetworkId(node.getName());
port.setPortGroup(spIdStr);
port.setStorageHADomain(haDomainUri);
List<Integer> opstatus = eport.getOperationalStatus();
Integer ok = 2;
if (opstatus.contains(ok)) {
port.setOperationalStatus(StoragePort.OperationalStatus.OK.name());
} else {
port.setOperationalStatus(StoragePort.OperationalStatus.NOT_OK.name());
}
VNXeIscsiPortal portal = node.getIscsiPortal();
if (portal != null) {
port.setIpAddress(portal.getIpAddress());
} else {
port.setOperationalStatus(StoragePort.OperationalStatus.NOT_OK.name());
}
_logger.info("Creating new storage port using NativeGuid : {}, IQN:", portNativeGuid, node.getName());
newStoragePorts.add(port);
} else {
existingStoragePorts.add(port);
}
port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
port.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
}
_logger.info("iSCSI port discovery for storage system {} complete", system.getId());
storagePorts.put(NEW, newStoragePorts);
storagePorts.put(EXISTING, existingStoragePorts);
return storagePorts;
}
use of com.emc.storageos.vnxe.models.VNXeIscsiPortal in project coprhd-controller by CoprHD.
the class VNXeApiClient method getAllIscsiPorts.
/**
* Get all iSCSI ports
*
* @return
*/
public List<VNXeIscsiNode> getAllIscsiPorts() {
IscsiNodeRequests nodeReq = new IscsiNodeRequests(_khClient);
List<VNXeIscsiNode> nodes = nodeReq.getAllNodes();
if (nodes != null && !nodes.isEmpty()) {
Iterator<VNXeIscsiNode> it = nodes.iterator();
while (it.hasNext()) {
VNXeIscsiNode node = it.next();
VNXeEthernetPort eport = node.getEthernetPort();
if (eport != null) {
String id = eport.getId();
EthernetPortRequests portRequest = new EthernetPortRequests(_khClient);
VNXeEthernetPort detailedPort = portRequest.get(id);
node.setEthernetPort(detailedPort);
// get iscsiPortal. comment it out for now, since API does not work.
IscsiPortalListRequest portalReq = new IscsiPortalListRequest(_khClient);
VNXeIscsiPortal portal = portalReq.getByIscsiNode(node.getId());
if (portal == null) {
it.remove();
} else {
node.setIscsiPortal(portal);
}
} else {
it.remove();
}
}
}
return nodes;
}
use of com.emc.storageos.vnxe.models.VNXeIscsiPortal in project coprhd-controller by CoprHD.
the class IscsiPortalListRequest method getByIscsiNode.
/**
* Get iscsiPort based on the IscsiNode Id
*
* @param nodeId iscsiNode id
* @return
*/
public VNXeIscsiPortal getByIscsiNode(String nodeId) {
StringBuilder builder = new StringBuilder(VNXeConstants.ISCSINODE_FILTER);
builder.append("\"");
builder.append(nodeId);
builder.append("\"");
setFilter(builder.toString());
VNXeIscsiPortal result = null;
List<VNXeIscsiPortal> portalList = get();
// it should just return 1
if (portalList != null && !portalList.isEmpty()) {
result = portalList.get(0);
} else {
_logger.info("No iscsiPortal found using the iscsiNode Id: {}", nodeId);
}
return result;
}
use of com.emc.storageos.vnxe.models.VNXeIscsiPortal in project coprhd-controller by CoprHD.
the class IscsiPortalListRequest method getDetails.
/**
* Get all iscsiPortals, with detailed iscsiNode.
*
* @return
*/
public List<VNXeIscsiPortal> getDetails() {
List<VNXeIscsiPortal> result = new ArrayList<VNXeIscsiPortal>();
List<VNXeIscsiPortal> portals = get();
if (portals != null && !portals.isEmpty()) {
for (VNXeIscsiPortal portal : portals) {
// get iscsiNode, so that we could get iqn name for each iscsi port
VNXeIscsiNode node = portal.getIscsiNode();
if (node != null) {
String nodeId = node.getId();
IscsiNodeRequests nodeReq = new IscsiNodeRequests(getClient());
VNXeIscsiNode detailedNode = nodeReq.get(nodeId);
portal.setIscsiNode(detailedNode);
result.add(portal);
}
}
}
return result;
}
use of com.emc.storageos.vnxe.models.VNXeIscsiPortal in project coprhd-controller by CoprHD.
the class VNXUnityCommunicationInterface method discoverIscsiPorts.
/**
* Discover iscsiPorts
*
* @param system
* @param client
* @param spIdMap
* storage processors VNXeId and ViPR URI map
* @return
* @throws VNXeException
*/
private HashMap<String, List<StoragePort>> discoverIscsiPorts(StorageSystem system, VNXeApiClient client, Map<String, URI> spIdMap) throws VNXeException {
HashMap<String, List<StoragePort>> storagePorts = new HashMap<String, List<StoragePort>>();
List<StoragePort> newStoragePorts = new ArrayList<StoragePort>();
List<StoragePort> existingStoragePorts = new ArrayList<StoragePort>();
_logger.info("Start iSCSI storage port discovery for storage system {}", system.getId());
// Retrieve the list of iscsi ports
List<VNXeIscsiNode> ports = client.getAllIscsiPorts();
if (ports == null || ports.isEmpty()) {
_logger.info("No iSCSI ports found for the system: {} ", system.getId());
return storagePorts;
}
_logger.info("Number iSCSI ports found: {}", ports.size());
// Create the list of storage ports.
for (VNXeIscsiNode node : ports) {
StoragePort port = null;
VNXeEthernetPort eport = node.getEthernetPort();
if (eport == null) {
_logger.info("No ethernet port found for the iscsi node: {}", node.getId());
continue;
}
VNXeBase spId = eport.getStorageProcessor();
if (spId == null) {
_logger.info("No storage processor info for the iscsi node: {}", node.getId());
continue;
}
String spIdStr = spId.getId();
URI haDomainUri = spIdMap.get(spIdStr);
if (haDomainUri == null) {
_logger.info("The sp {} has not been discovered.", spIdStr);
continue;
}
// Check if storage port was already discovered
String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, node.getName(), NativeGUIDGenerator.PORT);
URIQueryResultList results = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
Iterator<URI> it = results.iterator();
if (it.hasNext()) {
_logger.info("cross verifying for duplicate port");
StoragePort tmpPort = _dbClient.queryObject(StoragePort.class, it.next());
_logger.info(String.format("Actual StorageDevice %s : PortGroup found for port %s - Actual PortGroup %s", system.getId(), tmpPort.getPortNetworkId(), tmpPort.getPortGroup()));
if (tmpPort.getStorageDevice().equals(system.getId()) && tmpPort.getPortGroup().equals(spIdStr)) {
port = tmpPort;
_logger.info("found duplicate iscsi port {}", node.getName());
}
}
// If iscsi port was not previously discovered, add new storage port
if (port == null) {
port = new StoragePort();
port.setId(URIUtil.createId(StoragePort.class));
port.setLabel(portNativeGuid);
port.setTransportType("IP");
port.setNativeGuid(portNativeGuid);
port.setStorageDevice(system.getId());
port.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
port.setPortName(eport.getId());
port.setPortNetworkId(node.getName());
port.setPortGroup(spIdStr);
port.setStorageHADomain(haDomainUri);
VNXeIscsiPortal portal = node.getIscsiPortal();
if (portal != null) {
port.setIpAddress(portal.getIpAddress());
}
_logger.info("Creating new storage port using NativeGuid : {}, IQN:", portNativeGuid, node.getName());
newStoragePorts.add(port);
} else {
existingStoragePorts.add(port);
}
Health health = node.getEthernetPort().getHealth();
if (health != null && health.getValue() == Health.HealthEnum.OK.getValue()) {
port.setOperationalStatus(StoragePort.OperationalStatus.OK.name());
} else {
port.setOperationalStatus(StoragePort.OperationalStatus.NOT_OK.name());
}
port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
port.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
}
_logger.info("iSCSI port discovery for storage system {} complete", system.getId());
storagePorts.put(NEW, newStoragePorts);
storagePorts.put(EXISTING, existingStoragePorts);
return storagePorts;
}
Aggregations