private boolean createSCSIInitiatorsAndStoragePorts(StorageSystem storageSystem,String protectionDomainName,DiscoveredDataObject.CompatibilityStatus compatibilityStatus,String installationId,List<ScaleIOScsiInitiator> allSCSIInitiators,List<ScaleIOSDC> allSDCs,List<StoragePort> ports) throws IOException {
  boolean hasSCSIInitiators=false;
  if (allSDCs != null && allSCSIInitiators != null && !allSCSIInitiators.isEmpty()) {
    List<String> initiatorsToAddToNetwork=new ArrayList<>();
    String networkId=String.format("%s-IP",installationId);
    Network networkForSCSIInitiators=createIPNetworkForSCSIInitiators(networkId);
    for (    ScaleIOScsiInitiator scsiInit : allSCSIInitiators) {
      String id=scsiInit.getId();
      String iqn=scsiInit.getIqn();
      Initiator initiator=createSCSIInitiator(iqn,id);
      if (!networkForSCSIInitiators.hasEndpoint(initiator.getInitiatorPort())) {
        initiatorsToAddToNetwork.add(initiator.getInitiatorPort());
      }
      hasSCSIInitiators=true;
    }
    if (!initiatorsToAddToNetwork.isEmpty()) {
      networkForSCSIInitiators.addEndpoints(initiatorsToAddToNetwork,true);
      _dbClient.updateAndReindexObject(networkForSCSIInitiators);
    }
    List<StoragePort> iSCSIPorts=createSCSIStoragePorts(storageSystem,protectionDomainName,compatibilityStatus,networkForSCSIInitiators,allSDCs);
    ports.addAll(iSCSIPorts);
  }
  return hasSCSIInitiators;
}

private boolean createSCSIInitiatorsAndStoragePorts ( StorageSystem storageSystem , String protectionDomainName , DiscoveredDataObject . CompatibilityStatus compatibilityStatus , String installationId , List < ScaleIOScsiInitiator > allSCSIInitiators , List < ScaleIOSDC > allSDCs , List < StoragePort > ports ) throws IOException { boolean hasSCSIInitiators = false ; if ( allSDCs != null && allSCSIInitiators != null && ! allSCSIInitiators . isEmpty ( ) ) { List < String > initiatorsToAddToNetwork = new ArrayList < > ( ) ; String networkId = String . format ( "%s-IP" , installationId ) ; Network networkForSCSIInitiators = createIPNetworkForSCSIInitiators ( networkId ) ; for ( ScaleIOScsiInitiator scsiInit : allSCSIInitiators ) { String id = scsiInit . getId ( ) ; String iqn = scsiInit . getIqn ( ) ; Initiator initiator = createSCSIInitiator ( iqn , id ) ; if ( ! networkForSCSIInitiators . hasEndpoint ( initiator . getInitiatorPort ( ) ) ) { initiatorsToAddToNetwork . add ( initiator . getInitiatorPort ( ) ) ; } hasSCSIInitiators = true ; } if ( ! initiatorsToAddToNetwork . isEmpty ( ) ) { networkForSCSIInitiators . addEndpoints ( initiatorsToAddToNetwork , true ) ; _dbClient . updateAndReindexObject ( networkForSCSIInitiators ) ; } List < StoragePort > iSCSIPorts = createSCSIStoragePorts ( storageSystem , protectionDomainName , compatibilityStatus , networkForSCSIInitiators , allSDCs ) ; ports . addAll ( iSCSIPorts ) ; } return hasSCSIInitiators ; }
this will create an ip network for the sio system to contain the iscsi initiators associated with the system ( if any ) . it will also create the iscsi initiators and storageports , placing them in the ip network .
