Committed by
Gerrit Code Review
[ONOS-3486] Add the annotation of port mac when monitor switch added.L3
flows need external port mac information. Change-Id: I9afed351bd8d1641b8e9bef88718ec5c0ded8b5d
Showing
2 changed files
with
17 additions
and
9 deletions
... | @@ -113,6 +113,11 @@ public final class AnnotationKeys { | ... | @@ -113,6 +113,11 @@ public final class AnnotationKeys { |
113 | public static final String PORT_NAME = "portName"; | 113 | public static final String PORT_NAME = "portName"; |
114 | 114 | ||
115 | /** | 115 | /** |
116 | + * Annotation key for the port mac. | ||
117 | + */ | ||
118 | + public static final String PORT_MAC = "portMac"; | ||
119 | + | ||
120 | + /** | ||
116 | * Annotation key for the router ID. | 121 | * Annotation key for the router ID. |
117 | */ | 122 | */ |
118 | public static final String ROUTER_ID = "routerId"; | 123 | public static final String ROUTER_ID = "routerId"; | ... | ... |
... | @@ -516,7 +516,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -516,7 +516,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
516 | PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber()); | 516 | PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber()); |
517 | boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN) | 517 | boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN) |
518 | && !port.getConfig().contains(OFPortConfig.PORT_DOWN); | 518 | && !port.getConfig().contains(OFPortConfig.PORT_DOWN); |
519 | - SparseAnnotations annotations = makePortNameAnnotation(port.getName()); | 519 | + SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString()); |
520 | 520 | ||
521 | OFExpPortDescPropOpticalTransport firstProp = port.getProperties().get(0); | 521 | OFExpPortDescPropOpticalTransport firstProp = port.getProperties().get(0); |
522 | OFPortOpticalTransportSignalType sigType = firstProp.getPortSignalType(); | 522 | OFPortOpticalTransportSignalType sigType = firstProp.getPortSignalType(); |
... | @@ -560,16 +560,19 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -560,16 +560,19 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
560 | /** | 560 | /** |
561 | * Creates an annotation for the port name if one is available. | 561 | * Creates an annotation for the port name if one is available. |
562 | * | 562 | * |
563 | - * @param port description of the port | 563 | + * @param portName the port name |
564 | + * @param portMac the port mac | ||
564 | * @return annotation containing the port name if one is found, | 565 | * @return annotation containing the port name if one is found, |
565 | * null otherwise | 566 | * null otherwise |
566 | */ | 567 | */ |
567 | - private SparseAnnotations makePortNameAnnotation(String port) { | 568 | + private SparseAnnotations makePortAnnotation(String portName, String portMac) { |
568 | SparseAnnotations annotations = null; | 569 | SparseAnnotations annotations = null; |
569 | - String portName = Strings.emptyToNull(port); | 570 | + String pName = Strings.emptyToNull(portName); |
571 | + String pMac = Strings.emptyToNull(portMac); | ||
570 | if (portName != null) { | 572 | if (portName != null) { |
571 | annotations = DefaultAnnotations.builder() | 573 | annotations = DefaultAnnotations.builder() |
572 | - .set(AnnotationKeys.PORT_NAME, portName).build(); | 574 | + .set(AnnotationKeys.PORT_NAME, pName) |
575 | + .set(AnnotationKeys.PORT_MAC, pMac).build(); | ||
573 | } | 576 | } |
574 | return annotations; | 577 | return annotations; |
575 | } | 578 | } |
... | @@ -586,7 +589,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -586,7 +589,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
586 | !port.getState().contains(OFPortState.LINK_DOWN) && | 589 | !port.getState().contains(OFPortState.LINK_DOWN) && |
587 | !port.getConfig().contains(OFPortConfig.PORT_DOWN); | 590 | !port.getConfig().contains(OFPortConfig.PORT_DOWN); |
588 | Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER; | 591 | Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER; |
589 | - SparseAnnotations annotations = makePortNameAnnotation(port.getName()); | 592 | + SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString()); |
590 | return new DefaultPortDescription(portNo, enabled, type, | 593 | return new DefaultPortDescription(portNo, enabled, type, |
591 | portSpeed(port), annotations); | 594 | portSpeed(port), annotations); |
592 | } | 595 | } |
... | @@ -607,7 +610,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -607,7 +610,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
607 | 610 | ||
608 | boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN) | 611 | boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN) |
609 | && !port.getConfig().contains(OFPortConfig.PORT_DOWN); | 612 | && !port.getConfig().contains(OFPortConfig.PORT_DOWN); |
610 | - SparseAnnotations annotations = makePortNameAnnotation(port.getName()); | 613 | + SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString()); |
611 | 614 | ||
612 | if (port.getVersion() == OFVersion.OF_13 | 615 | if (port.getVersion() == OFVersion.OF_13 |
613 | && ptype == PortDescPropertyType.OPTICAL_TRANSPORT) { | 616 | && ptype == PortDescPropertyType.OPTICAL_TRANSPORT) { |
... | @@ -649,7 +652,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -649,7 +652,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
649 | 652 | ||
650 | // FIXME when Calient OF agent reports port status | 653 | // FIXME when Calient OF agent reports port status |
651 | boolean enabled = true; | 654 | boolean enabled = true; |
652 | - SparseAnnotations annotations = makePortNameAnnotation(port.getName()); | 655 | + SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString()); |
653 | 656 | ||
654 | // S160 data sheet | 657 | // S160 data sheet |
655 | // Wavelength range: 1260 - 1630 nm, grid is irrelevant for this type of switch | 658 | // Wavelength range: 1260 - 1630 nm, grid is irrelevant for this type of switch |
... | @@ -664,7 +667,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -664,7 +667,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
664 | } else { | 667 | } else { |
665 | PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber()); | 668 | PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber()); |
666 | Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER; | 669 | Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER; |
667 | - SparseAnnotations annotations = makePortNameAnnotation(port.getName()); | 670 | + SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString()); |
668 | return new DefaultPortDescription(portNo, false, type, | 671 | return new DefaultPortDescription(portNo, false, type, |
669 | portSpeed(port), annotations); | 672 | portSpeed(port), annotations); |
670 | } | 673 | } | ... | ... |
-
Please register or login to post a comment