Beispiel #1
0
  @Override
  public void addInterfaces(MainScreen parent, Node node) {

    String[] choices = {
      "5 Ethernet-TX ports simple switch.",
      "8 Ethernet-TX ports switch.",
      "12 Ethernet-TX ports switch.",
      "24 Ethernet-TX ports switch.",
      "12 Ethernet-TX ports with 2 Ethernet-FX switch.",
      "24 Ethernet-TX ports with 2 Ethernet-FX switch.",
      "12 Ethernet-FX ports with 2 Ethernet-TX switch.",
      "24 Ethernet-FX ports with 2 Ethernet-TX switch."
    };

    String choice =
        parent.getDeviceTypeDialog("Create new switch", "Please choose switch type", choices);

    int tx = 0, fx = 0;

    if (choice.contains(choices[0])) {
      tx = 5;
      fx = 0;
    } else if (choice.contains(choices[1])) {
      tx = 8;
      fx = 0;
    } else if (choice.contains(choices[2])) {
      tx = 12;
      fx = 0;
    } else if (choice.contains(choices[3])) {
      tx = 24;
      fx = 0;
    } else if (choice.contains(choices[4])) {
      tx = 12;
      fx = 2;
    } else if (choice.contains(choices[5])) {
      tx = 24;
      fx = 2;
    } else if (choice.contains(choices[6])) {
      tx = 2;
      fx = 12;
    } else if (choice.contains(choices[7])) {
      tx = 2;
      fx = 24;
    }

    for (int i = 0; i < tx; i++) {
      node.addNetworkInterface(
          core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet10T) + String.valueOf(i),
          core.NetworkInterface.Ethernet10T,
          false);
    }

    for (int i = 0; i < fx; i++) {
      node.addNetworkInterface(
          core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet100FX) + String.valueOf(i),
          core.NetworkInterface.Ethernet100FX,
          false);
    }
  }