예제 #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);
    }
  }
예제 #2
0
  /**
   * This method adds to virtual model all necessary information to store a virtual link: 1) Builds
   * a source and a sink virtual interface. 2) Links virtual interfaces to virtual devices (source
   * and sink). 3) Links virtual link with physical link.
   *
   * @param virtualPath
   * @param sourceId
   * @param sinkId
   * @throws ResourceNotFoundException
   */
  private void addVirtualLink(
      org.opennaas.extensions.network.model.topology.Path virtualPath, int sourceId, int sinkId)
      throws ResourceNotFoundException {

    VirtualInterface vIfaceSource = new VirtualInterface();
    VirtualInterface vIfaceSink = new VirtualInterface();

    VirtualDevice sourceDevice =
        (VirtualDevice)
            NetworkModelHelper.getDeviceByName(mappingNetworkResult, String.valueOf(sourceId));
    VirtualDevice sinkDevice =
        (VirtualDevice)
            NetworkModelHelper.getDeviceByName(mappingNetworkResult, String.valueOf(sinkId));

    vIfaceSource.setDevice(sourceDevice);
    vIfaceSink.setDevice(sinkDevice);

    VirtualLink vlink = new VirtualLink();

    String sourcePhyDevice = sourceDevice.getImplementedBy();
    String sinkPhyDevice = sinkDevice.getImplementedBy();

    List<Link> links =
        NetworkModelHelper.getAllLinksBetweenTwoDevices(
            (NetworkModel) physicalNetworkModel, sourcePhyDevice, sinkPhyDevice);

    if (links.isEmpty())
      throw new ResourceNotFoundException(
          "No physical links between physical devices "
              + sourcePhyDevice
              + " and "
              + sinkPhyDevice);

    vlink.setImplementedBy(links.get(0).getName());
    vlink.setSource(vIfaceSource);
    vlink.setSink(vIfaceSink);

    virtualPath.getPathSegments().add(vlink);

    mappingNetworkResult.getNetworkElements().add(vlink);
  }
예제 #3
0
  private void addVirtualDeviceToModel(int phyNodeId) throws ResourceNotFoundException {

    List<NetworkElement> vDevices =
        NetworkModelHelper.getNetworkElementsByClassName(
            VirtualDevice.class, mappingNetworkResult.getNetworkElements());

    int virtualId = vDevices.size();

    String phyDeviceId = inpNetwork.getNodes().get(phyNodeId).getPnodeID();

    Device device = NetworkModelHelper.getDeviceByName(physicalNetworkModel, phyDeviceId);

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

    VirtualDevice vDevice = new VirtualDevice();
    vDevice.setName(String.valueOf(virtualId));
    vDevice.setImplementedBy(phyDeviceId);

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