/**
   * Creates or modifies IP/iSCSI ports
   *
   * <p>Steps- 1. Get all iSCSI ports of the storage system. 2. If single port is present - a) Check
   * if it contains valid IQN as port network Id. b) If it does not contain the valid IQN, then just
   * update its port network id. c) If it contains the valid IQN as port network id and that port
   * network id does not equal the one received in the response, then create new port. 3. If there
   * are more than one ports a) Form a list of port network ids by iterating all storage port
   * instances. b) Check if the IQN is present in the list constructed in 3.a. c) If it is not
   * present in the list 3.a, then create a new port.
   *
   * @param iqn
   */
  private void performISCSIOperation(String iqn) {
    logger.info(
        "Start iSCSI Ports create/modify operations," + " for storage system : {} ",
        storageSystem.getId());

    List<StoragePort> iscsiPorts = getISCSIPorts();
    if (iscsiPorts.size() == 1) {
      // If there is only a port, check if the networkId is the IQN
      // If it is not IQN, then update it with the IQN received in the response.
      StoragePort singlePort = iscsiPorts.get(0);
      String portNetworkId = singlePort.getPortNetworkId();
      if (!StorageProtocol.checkInitiator(Block.iSCSI.name(), null, portNetworkId)) {
        modify(singlePort, iqn);
      } else {
        // It is IQN, check if the port's IQN matches with the IQN received
        // If it does not match, just create the new IP port.
        if (!portNetworkId.equalsIgnoreCase(iqn)) {
          create(iqn, StorageProtocol.Transport.IP.name());
        }
      }

    } else {
      List<String> portNetworkIdsList = new ArrayList<String>();
      // If there are more than 1 ports, construct a list of portNetworkIds
      for (StoragePort port : iscsiPorts) {
        portNetworkIdsList.add(port.getPortNetworkId());
      }

      // Now, check if the IQN in the response is already present in the
      // existing portNetworkIds list. If it is not present, then create new IP port.
      if (!portNetworkIdsList.contains(iqn)) {
        create(iqn, StorageProtocol.Transport.IP.name());
      }
    }

    logger.info(
        "End iSCSI Ports create/modify operations," + " for storage system :{}",
        storageSystem.getId());
  }
 /*
  * Filters iSCSI ports from all port list
  */
 private List<StoragePort> getISCSIPorts() {
   return filterPortsByType(StorageProtocol.Transport.IP.name());
 }