Exemplo n.º 1
0
 /**
  * Verifies that Annotations created by merging {@code annotations} is equal to actual
  * Annotations.
  *
  * @param actual Annotations to check
  * @param annotations
  */
 private static void assertAnnotationsEquals(
     Annotations actual, SparseAnnotations... annotations) {
   SparseAnnotations expected = DefaultAnnotations.builder().build();
   for (SparseAnnotations a : annotations) {
     expected = DefaultAnnotations.union(expected, a);
   }
   assertEquals(expected.keys(), actual.keys());
   for (String key : expected.keys()) {
     assertEquals(expected.value(key), actual.value(key));
   }
 }
Exemplo n.º 2
0
 private void updatePorts(ConnectPoint src, ConnectPoint dst, SparseAnnotations annotations) {
   final String linkType = annotations.value("optical.type");
   if ("cross-connect".equals(linkType)) {
     String value = annotations.value("bandwidth").trim();
     try {
       double bw = Double.parseDouble(value);
       updateOchPort(bw, src, dst);
     } catch (NumberFormatException e) {
       log.warn("Invalid bandwidth ({}), can't configure port(s)", value);
       return;
     }
   } else if ("WDM".equals(linkType)) {
     String value = annotations.value("optical.waves").trim();
     try {
       int numChls = Integer.parseInt(value);
       updateOMSPorts(numChls, src, dst);
     } catch (NumberFormatException e) {
       log.warn("Invalid channel ({}), can't configure port(s)", value);
       return;
     }
   }
 }
Exemplo n.º 3
0
 /**
  * Generates an annotation from an existing annotation and DeviceConfig.
  *
  * @param bdc the device config entity from network config
  * @param an the annotation
  * @return annotation combining both sources
  */
 public static SparseAnnotations combine(BasicDeviceConfig bdc, SparseAnnotations an) {
   DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
   if (bdc.driver() != an.value(AnnotationKeys.DRIVER)) {
     newBuilder.set(AnnotationKeys.DRIVER, bdc.driver());
   }
   if (bdc.name() != null) {
     newBuilder.set(AnnotationKeys.NAME, bdc.name());
   }
   if (bdc.latitude() != DEFAULT_COORD) {
     newBuilder.set(AnnotationKeys.LATITUDE, Double.toString(bdc.latitude()));
   }
   if (bdc.longitude() != DEFAULT_COORD) {
     newBuilder.set(AnnotationKeys.LONGITUDE, Double.toString(bdc.longitude()));
   }
   if (bdc.rackAddress() != null) {
     newBuilder.set(AnnotationKeys.RACK_ADDRESS, bdc.rackAddress());
   }
   if (bdc.owner() != null) {
     newBuilder.set(AnnotationKeys.OWNER, bdc.owner());
   }
   DefaultAnnotations newAnnotations = newBuilder.build();
   return DefaultAnnotations.union(an, newAnnotations);
 }