static void printScsiTopology(HostScsiTopology hst) { HostScsiTopologyInterface[] hstis = hst.getAdapter(); for(int i=0; hstis!=null && i<hstis.length; i++) { System.out.println("Adapter:" + hstis[i].getAdapter()); System.out.println("Key:" + hstis[i].getKey()); HostScsiTopologyTarget[] hstts = hstis[i].getTarget(); for(int j=0; hstts!=null && j<hstts.length; j++) { System.out.println("Key:" + hstts[j].getKey()); System.out.println("Target:" + hstts[j].getTarget()); System.out.println("Transport:" + hstts[j].getTransport().getClass().getName()); HostScsiTopologyLun[] luns = hstts[j].getLun(); for(int k=0; luns!=null && k<luns.length; k++) { System.out.println("Key:" + luns[k].getKey()); System.out.println("LUN:" + luns[k].getLun()); System.out.println("ScsiLun:" + luns[k].getScsiLun()); } } } }
private static HostScsiDisk getHostScsiDisk(HostScsiTopology hst, List<HostScsiDisk> lstHostScsiDisks, String iqn) { for (HostScsiTopologyInterface adapter : hst.getAdapter()) { if (adapter.getTarget() != null) { for (HostScsiTopologyTarget target : adapter.getTarget()) { if (target.getTransport() instanceof HostInternetScsiTargetTransport) { String iScsiName = ((HostInternetScsiTargetTransport)target.getTransport()).getIScsiName(); if (iqn.equals(iScsiName)) { for (HostScsiDisk hostScsiDisk : lstHostScsiDisks) { for (HostScsiTopologyLun hstl : target.getLun()) { if (hstl.getScsiLun().contains(hostScsiDisk.getUuid())) { return hostScsiDisk; } } } } } } } } return null; }