public DriverTask unexportVolumesFromInitiators(List<Initiator> initiators,List<StorageVolume> volumes){
  LOG.info("Unexporting volumes from initiators");
  DriverTask task=new DellSCDriverTask("unexportVolumes");
  ScServer server=null;
  StringBuilder errBuffer=new StringBuilder();
  int volumesUnmapped=0;
  for (  StorageVolume volume : volumes) {
    String ssn=volume.getStorageSystemId();
    boolean isSnapshot=StringUtils.countMatches(volume.getNativeId(),".") == 2;
    try {
      StorageCenterAPI api=connectionManager.getConnection(ssn);
      ScVolume scVol=null;
      if (isSnapshot) {
        scVol=api.findReplayView(volume.getNativeId());
        if (scVol != null) {
          api.deleteVolume(scVol.instanceId);
          volumesUnmapped++;
          continue;
        }
      }
 else {
        scVol=api.getVolume(volume.getNativeId());
      }
      if (scVol == null) {
        throw new DellSCDriverException(String.format("Unable to find volume %s",volume.getNativeId()));
      }
      if (server == null) {
        server=findScServer(api,ssn,initiators);
      }
      if (server == null) {
        throw new DellSCDriverException(SERVER_CREATE_FAIL_MSG);
      }
      ScMappingProfile[] mappingProfiles=api.findMappingProfiles(server.instanceId,scVol.instanceId);
      for (      ScMappingProfile mappingProfile : mappingProfiles) {
        api.deleteMappingProfile(mappingProfile.instanceId);
      }
      volumesUnmapped++;
      LOG.info("Volume '{}' unexported from server '{}'",scVol.name,server.name);
    }
 catch (    StorageCenterAPIException|DellSCDriverException dex) {
      String error=String.format("Error unmapping volume %s: %s",volume.getDisplayName(),dex);
      LOG.error(error);
      errBuffer.append(String.format("%s%n",error));
      if (SERVER_CREATE_FAIL_MSG.equals(dex.getMessage())) {
        break;
      }
    }
  }
  task.setMessage(errBuffer.toString());
  if (volumesUnmapped == volumes.size()) {
    task.setStatus(TaskStatus.READY);
  }
 else   if (volumesUnmapped == 0) {
    task.setStatus(TaskStatus.FAILED);
  }
 else {
    task.setStatus(TaskStatus.PARTIALLY_FAILED);
  }
  return task;
}

public DriverTask unexportVolumesFromInitiators ( List < Initiator > initiators , List < StorageVolume > volumes ) { LOG . info ( "Unexporting volumes from initiators" ) ; DriverTask task = new DellSCDriverTask ( "unexportVolumes" ) ; ScServer server = null ; StringBuilder errBuffer = new StringBuilder ( ) ; int volumesUnmapped = 0 ; for ( StorageVolume volume : volumes ) { String ssn = volume . getStorageSystemId ( ) ; boolean isSnapshot = StringUtils . countMatches ( volume . getNativeId ( ) , "." ) == 2 ; try { StorageCenterAPI api = connectionManager . getConnection ( ssn ) ; ScVolume scVol = null ; if ( isSnapshot ) { scVol = api . findReplayView ( volume . getNativeId ( ) ) ; if ( scVol != null ) { api . deleteVolume ( scVol . instanceId ) ; volumesUnmapped ++ ; continue ; } } else { scVol = api . getVolume ( volume . getNativeId ( ) ) ; } if ( scVol == null ) { throw new DellSCDriverException ( String . format ( "Unable to find volume %s" , volume . getNativeId ( ) ) ) ; } if ( server == null ) { server = findScServer ( api , ssn , initiators ) ; } if ( server == null ) { throw new DellSCDriverException ( SERVER_CREATE_FAIL_MSG ) ; } ScMappingProfile [ ] mappingProfiles = api . findMappingProfiles ( server . instanceId , scVol . instanceId ) ; for ( ScMappingProfile mappingProfile : mappingProfiles ) { api . deleteMappingProfile ( mappingProfile . instanceId ) ; } volumesUnmapped ++ ; LOG . info ( "Volume '{}' unexported from server '{}'" , scVol . name , server . name ) ; } catch ( StorageCenterAPIException | DellSCDriverException dex ) { String error = String . format ( "Error unmapping volume %s: %s" , volume . getDisplayName ( ) , dex ) ; LOG . error ( error ) ; errBuffer . append ( String . format ( "%s%n" , error ) ) ; if ( SERVER_CREATE_FAIL_MSG . equals ( dex . getMessage ( ) ) ) { break ; } } } task . setMessage ( errBuffer . toString ( ) ) ; if ( volumesUnmapped == volumes . size ( ) ) { task . setStatus ( TaskStatus . READY ) ; } else if ( volumesUnmapped == 0 ) { task . setStatus ( TaskStatus . FAILED ) ; } else { task . setStatus ( TaskStatus . PARTIALLY_FAILED ) ; } return task ; }
remove volume exports to initiators .
