private URI createEthernetStoragePort(Map<String,Object> keyMap,StoragePort port,String name,String portInstanceID,List<StoragePort> newPorts,List<StoragePort> existingPorts) throws IOException {
  StoragePort portinMemory=(StoragePort)keyMap.get(portInstanceID);
  if (null == port) {
    portinMemory.setPortNetworkId(name);
    portinMemory.setPortEndPointID(name);
    String portNativeGuid=NativeGUIDGenerator.generateNativeGuid(_dbClient,portinMemory);
    portinMemory.setNativeGuid(portNativeGuid);
    portinMemory.setLabel(portNativeGuid);
    _dbClient.createObject(portinMemory);
    newPorts.add(portinMemory);
    return portinMemory.getId();
  }
 else {
    port.setPortName(portinMemory.getPortName());
    port.setPortSpeed(portinMemory.getPortSpeed());
    port.setPortEndPointID(name);
    port.setCompatibilityStatus(portinMemory.getCompatibilityStatus());
    port.setDiscoveryStatus(portinMemory.getDiscoveryStatus());
    port.setOperationalStatus(portinMemory.getOperationalStatus());
    port.setPortType(portinMemory.getPortType());
    _dbClient.persistObject(port);
    existingPorts.add(port);
    return port.getId();
  }
}

private URI createEthernetStoragePort ( Map < String , Object > keyMap , StoragePort port , String name , String portInstanceID , List < StoragePort > newPorts , List < StoragePort > existingPorts ) throws IOException { StoragePort portinMemory = ( StoragePort ) keyMap . get ( portInstanceID ) ; if ( null == port ) { portinMemory . setPortNetworkId ( name ) ; portinMemory . setPortEndPointID ( name ) ; String portNativeGuid = NativeGUIDGenerator . generateNativeGuid ( _dbClient , portinMemory ) ; portinMemory . setNativeGuid ( portNativeGuid ) ; portinMemory . setLabel ( portNativeGuid ) ; _dbClient . createObject ( portinMemory ) ; newPorts . add ( portinMemory ) ; return portinMemory . getId ( ) ; } else { port . setPortName ( portinMemory . getPortName ( ) ) ; port . setPortSpeed ( portinMemory . getPortSpeed ( ) ) ; port . setPortEndPointID ( name ) ; port . setCompatibilityStatus ( portinMemory . getCompatibilityStatus ( ) ) ; port . setDiscoveryStatus ( portinMemory . getDiscoveryStatus ( ) ) ; port . setOperationalStatus ( portinMemory . getOperationalStatus ( ) ) ; port . setPortType ( portinMemory . getPortType ( ) ) ; _dbClient . persistObject ( port ) ; existingPorts . add ( port ) ; return port . getId ( ) ; } }
create ethernet storage port . storageports would have been created in storageports processor , but for ethernet those will not get updated to db , as to get scsiaddress , we need a different smi class protocolendpoint algo : 1 . check if storageethernet port available in db . 2 . if not , then get already created storageport , update scsi address and persist . 3 . if yes , then just update the properties alone .
