Exemplo n.º 1
0
  private void parseVirtualDevices() throws ResourceNotFoundException {

    for (int i = 0; i < mappingResult.getVnodes().size(); i++) {

      int vnodeId = mappingResult.getVnodes().get(i);
      String deviceId = inpNetwork.getNodes().get(vnodeId).getPnodeID();
      Device device = NetworkModelHelper.getDeviceByName(physicalNetworkModel, deviceId);

      if (device == null)
        throw new ResourceNotFoundException(
            "Device " + deviceId + " not found in network topology.");

      VirtualDevice vDevice = new VirtualDevice();
      vDevice.setName(String.valueOf(i));
      vDevice.setImplementedBy(deviceId);

      mappingNetworkResult.getNetworkElements().add(vDevice);
    }
  }
Exemplo n.º 2
0
  private void parseVirtualLinks() throws ResourceNotFoundException {

    ArrayList<ArrayList<VNTLinkMappingCell>> resultLinks = mappingResult.getVNTLinkMappingArray();

    for (int i = 0; i < (int) resultLinks.size(); i++) {
      for (int j = 0; j < (int) resultLinks.get(i).size(); j++) {
        if (resultLinks.get(i).get(j).getIsMapped() == 1) {

          // all this block constructs the virtual network

          Path path;

          if (i < j) {
            resultLinks
                .get(i)
                .get(j)
                .getResultPath()
                .setNode1Id(Integer.valueOf(mappingResult.getVnodes().get(i).toString()));
            resultLinks
                .get(i)
                .get(j)
                .getResultPath()
                .setNode2Id(Integer.valueOf(mappingResult.getVnodes().get(j).toString()));
            path = resultLinks.get(i).get(j).getResultPath();

          } else {
            resultLinks
                .get(j)
                .get(i)
                .getResultPath()
                .setNode1Id(Integer.valueOf(mappingResult.getVnodes().get(j).toString()));
            resultLinks
                .get(j)
                .get(i)
                .getResultPath()
                .setNode2Id(Integer.valueOf(mappingResult.getVnodes().get(i).toString()));
            path = resultLinks.get(j).get(i).getResultPath();
          }

          // binds to physical path
          org.opennaas.extensions.network.model.topology.Path virtualPath =
              new org.opennaas.extensions.network.model.topology.Path();

          String sourceId = String.valueOf(Math.min(i, j));
          String sinkId = String.valueOf(Math.max(i, j));
          virtualPath.setName(sourceId + "-" + sinkId);

          for (int k = 0; k < path.getLinks().size(); k++) {

            int phySourceId = path.getLinks().get(k).getNode1Id();
            int phySinkId = path.getLinks().get(k).getNode2Id();

            int vSourceId = getVirtualDeviceIdByPhysicalId(phySourceId);
            int vSinkId = getVirtualDeviceIdByPhysicalId(phySinkId);

            if (!isVirtualNodeAlreadyAdded(vSourceId)) addVirtualDeviceToModel(phySourceId);

            if (!isVirtualNodeAlreadyAdded(vSinkId)) addVirtualDeviceToModel(phySinkId);

            addVirtualLink(virtualPath, vSourceId, vSinkId);
          }

          mappingNetworkResult.getNetworkElements().add(virtualPath);
        }
      }
    }
  }