lldp discovery independent of OF
Change-Id: I720f727f6628e30e5d732e6d7bf742d1b7050812
Showing
42 changed files
with
618 additions
and
92 deletions
| ... | @@ -90,11 +90,15 @@ public class IntentPushTestCommand extends AbstractShellCommand | ... | @@ -90,11 +90,15 @@ public class IntentPushTestCommand extends AbstractShellCommand |
| 90 | service.submit(intent); | 90 | service.submit(intent); |
| 91 | } | 91 | } |
| 92 | try { | 92 | try { |
| 93 | - latch.await(5, TimeUnit.SECONDS); | 93 | + if (latch.await(10, TimeUnit.SECONDS)) { |
| 94 | - printResults(count); | 94 | + printResults(count); |
| 95 | + } else { | ||
| 96 | + print("I FAIL MISERABLY -> %d", latch.getCount()); | ||
| 97 | + } | ||
| 95 | } catch (InterruptedException e) { | 98 | } catch (InterruptedException e) { |
| 96 | print(e.toString()); | 99 | print(e.toString()); |
| 97 | } | 100 | } |
| 101 | + | ||
| 98 | service.removeListener(this); | 102 | service.removeListener(this); |
| 99 | } | 103 | } |
| 100 | 104 | ||
| ... | @@ -140,6 +144,8 @@ public class IntentPushTestCommand extends AbstractShellCommand | ... | @@ -140,6 +144,8 @@ public class IntentPushTestCommand extends AbstractShellCommand |
| 140 | } else { | 144 | } else { |
| 141 | log.warn("install event latch is null"); | 145 | log.warn("install event latch is null"); |
| 142 | } | 146 | } |
| 147 | + } else { | ||
| 148 | + log.info("I FAIL -> {}", event); | ||
| 143 | } | 149 | } |
| 144 | } | 150 | } |
| 145 | } | 151 | } | ... | ... |
| 1 | package org.onlab.onos.net; | 1 | package org.onlab.onos.net; |
| 2 | 2 | ||
| 3 | import org.onlab.onos.net.provider.ProviderId; | 3 | import org.onlab.onos.net.provider.ProviderId; |
| 4 | +import org.onlab.packet.ChassisId; | ||
| 4 | 5 | ||
| 5 | import java.util.Objects; | 6 | import java.util.Objects; |
| 6 | 7 | ||
| ... | @@ -16,6 +17,7 @@ public class DefaultDevice extends AbstractElement implements Device { | ... | @@ -16,6 +17,7 @@ public class DefaultDevice extends AbstractElement implements Device { |
| 16 | private final String serialNumber; | 17 | private final String serialNumber; |
| 17 | private final String hwVersion; | 18 | private final String hwVersion; |
| 18 | private final String swVersion; | 19 | private final String swVersion; |
| 20 | + private final ChassisId chassisId; | ||
| 19 | 21 | ||
| 20 | // For serialization | 22 | // For serialization |
| 21 | private DefaultDevice() { | 23 | private DefaultDevice() { |
| ... | @@ -24,6 +26,7 @@ public class DefaultDevice extends AbstractElement implements Device { | ... | @@ -24,6 +26,7 @@ public class DefaultDevice extends AbstractElement implements Device { |
| 24 | this.hwVersion = null; | 26 | this.hwVersion = null; |
| 25 | this.swVersion = null; | 27 | this.swVersion = null; |
| 26 | this.serialNumber = null; | 28 | this.serialNumber = null; |
| 29 | + this.chassisId = null; | ||
| 27 | } | 30 | } |
| 28 | 31 | ||
| 29 | /** | 32 | /** |
| ... | @@ -40,13 +43,15 @@ public class DefaultDevice extends AbstractElement implements Device { | ... | @@ -40,13 +43,15 @@ public class DefaultDevice extends AbstractElement implements Device { |
| 40 | */ | 43 | */ |
| 41 | public DefaultDevice(ProviderId providerId, DeviceId id, Type type, | 44 | public DefaultDevice(ProviderId providerId, DeviceId id, Type type, |
| 42 | String manufacturer, String hwVersion, String swVersion, | 45 | String manufacturer, String hwVersion, String swVersion, |
| 43 | - String serialNumber, Annotations... annotations) { | 46 | + String serialNumber, ChassisId chassisId, |
| 47 | + Annotations... annotations) { | ||
| 44 | super(providerId, id, annotations); | 48 | super(providerId, id, annotations); |
| 45 | this.type = type; | 49 | this.type = type; |
| 46 | this.manufacturer = manufacturer; | 50 | this.manufacturer = manufacturer; |
| 47 | this.hwVersion = hwVersion; | 51 | this.hwVersion = hwVersion; |
| 48 | this.swVersion = swVersion; | 52 | this.swVersion = swVersion; |
| 49 | this.serialNumber = serialNumber; | 53 | this.serialNumber = serialNumber; |
| 54 | + this.chassisId = chassisId; | ||
| 50 | } | 55 | } |
| 51 | 56 | ||
| 52 | @Override | 57 | @Override |
| ... | @@ -80,6 +85,11 @@ public class DefaultDevice extends AbstractElement implements Device { | ... | @@ -80,6 +85,11 @@ public class DefaultDevice extends AbstractElement implements Device { |
| 80 | } | 85 | } |
| 81 | 86 | ||
| 82 | @Override | 87 | @Override |
| 88 | + public ChassisId chassisId() { | ||
| 89 | + return chassisId; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @Override | ||
| 83 | public int hashCode() { | 93 | public int hashCode() { |
| 84 | return Objects.hash(id, type, manufacturer, hwVersion, swVersion, serialNumber); | 94 | return Objects.hash(id, type, manufacturer, hwVersion, swVersion, serialNumber); |
| 85 | } | 95 | } | ... | ... |
| 1 | package org.onlab.onos.net; | 1 | package org.onlab.onos.net; |
| 2 | 2 | ||
| 3 | +import org.onlab.packet.ChassisId; | ||
| 4 | + | ||
| 3 | /** | 5 | /** |
| 4 | * Representation of a network infrastructure device. | 6 | * Representation of a network infrastructure device. |
| 5 | */ | 7 | */ |
| ... | @@ -54,6 +56,13 @@ public interface Device extends Element { | ... | @@ -54,6 +56,13 @@ public interface Device extends Element { |
| 54 | */ | 56 | */ |
| 55 | String serialNumber(); | 57 | String serialNumber(); |
| 56 | 58 | ||
| 59 | + /** | ||
| 60 | + * Returns the device chassis id. | ||
| 61 | + * | ||
| 62 | + * @return chassis id | ||
| 63 | + */ | ||
| 64 | + ChassisId chassisId(); | ||
| 65 | + | ||
| 57 | // Device realizedBy(); ? | 66 | // Device realizedBy(); ? |
| 58 | 67 | ||
| 59 | // ports are not provided directly, but rather via DeviceService.getPorts(Device device); | 68 | // ports are not provided directly, but rather via DeviceService.getPorts(Device device); | ... | ... |
| ... | @@ -2,6 +2,7 @@ package org.onlab.onos.net.device; | ... | @@ -2,6 +2,7 @@ package org.onlab.onos.net.device; |
| 2 | 2 | ||
| 3 | import org.onlab.onos.net.AbstractDescription; | 3 | import org.onlab.onos.net.AbstractDescription; |
| 4 | import org.onlab.onos.net.SparseAnnotations; | 4 | import org.onlab.onos.net.SparseAnnotations; |
| 5 | +import org.onlab.packet.ChassisId; | ||
| 5 | 6 | ||
| 6 | import java.net.URI; | 7 | import java.net.URI; |
| 7 | 8 | ||
| ... | @@ -20,6 +21,7 @@ public class DefaultDeviceDescription extends AbstractDescription | ... | @@ -20,6 +21,7 @@ public class DefaultDeviceDescription extends AbstractDescription |
| 20 | private final String hwVersion; | 21 | private final String hwVersion; |
| 21 | private final String swVersion; | 22 | private final String swVersion; |
| 22 | private final String serialNumber; | 23 | private final String serialNumber; |
| 24 | + private final ChassisId chassisId; | ||
| 23 | 25 | ||
| 24 | /** | 26 | /** |
| 25 | * Creates a device description using the supplied information. | 27 | * Creates a device description using the supplied information. |
| ... | @@ -34,7 +36,7 @@ public class DefaultDeviceDescription extends AbstractDescription | ... | @@ -34,7 +36,7 @@ public class DefaultDeviceDescription extends AbstractDescription |
| 34 | */ | 36 | */ |
| 35 | public DefaultDeviceDescription(URI uri, Type type, String manufacturer, | 37 | public DefaultDeviceDescription(URI uri, Type type, String manufacturer, |
| 36 | String hwVersion, String swVersion, | 38 | String hwVersion, String swVersion, |
| 37 | - String serialNumber, | 39 | + String serialNumber, ChassisId chassis, |
| 38 | SparseAnnotations... annotations) { | 40 | SparseAnnotations... annotations) { |
| 39 | super(annotations); | 41 | super(annotations); |
| 40 | this.uri = checkNotNull(uri, "Device URI cannot be null"); | 42 | this.uri = checkNotNull(uri, "Device URI cannot be null"); |
| ... | @@ -43,6 +45,7 @@ public class DefaultDeviceDescription extends AbstractDescription | ... | @@ -43,6 +45,7 @@ public class DefaultDeviceDescription extends AbstractDescription |
| 43 | this.hwVersion = hwVersion; | 45 | this.hwVersion = hwVersion; |
| 44 | this.swVersion = swVersion; | 46 | this.swVersion = swVersion; |
| 45 | this.serialNumber = serialNumber; | 47 | this.serialNumber = serialNumber; |
| 48 | + this.chassisId = chassis; | ||
| 46 | } | 49 | } |
| 47 | 50 | ||
| 48 | /** | 51 | /** |
| ... | @@ -54,7 +57,7 @@ public class DefaultDeviceDescription extends AbstractDescription | ... | @@ -54,7 +57,7 @@ public class DefaultDeviceDescription extends AbstractDescription |
| 54 | SparseAnnotations... annotations) { | 57 | SparseAnnotations... annotations) { |
| 55 | this(base.deviceURI(), base.type(), base.manufacturer(), | 58 | this(base.deviceURI(), base.type(), base.manufacturer(), |
| 56 | base.hwVersion(), base.swVersion(), base.serialNumber(), | 59 | base.hwVersion(), base.swVersion(), base.serialNumber(), |
| 57 | - annotations); | 60 | + base.chassisId(), annotations); |
| 58 | } | 61 | } |
| 59 | 62 | ||
| 60 | @Override | 63 | @Override |
| ... | @@ -88,6 +91,11 @@ public class DefaultDeviceDescription extends AbstractDescription | ... | @@ -88,6 +91,11 @@ public class DefaultDeviceDescription extends AbstractDescription |
| 88 | } | 91 | } |
| 89 | 92 | ||
| 90 | @Override | 93 | @Override |
| 94 | + public ChassisId chassisId() { | ||
| 95 | + return chassisId; | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + @Override | ||
| 91 | public String toString() { | 99 | public String toString() { |
| 92 | return toStringHelper(this) | 100 | return toStringHelper(this) |
| 93 | .add("uri", uri).add("type", type).add("mfr", manufacturer) | 101 | .add("uri", uri).add("type", type).add("mfr", manufacturer) |
| ... | @@ -104,5 +112,6 @@ public class DefaultDeviceDescription extends AbstractDescription | ... | @@ -104,5 +112,6 @@ public class DefaultDeviceDescription extends AbstractDescription |
| 104 | this.hwVersion = null; | 112 | this.hwVersion = null; |
| 105 | this.swVersion = null; | 113 | this.swVersion = null; |
| 106 | this.serialNumber = null; | 114 | this.serialNumber = null; |
| 115 | + this.chassisId = null; | ||
| 107 | } | 116 | } |
| 108 | } | 117 | } | ... | ... |
| ... | @@ -2,6 +2,7 @@ package org.onlab.onos.net.device; | ... | @@ -2,6 +2,7 @@ package org.onlab.onos.net.device; |
| 2 | 2 | ||
| 3 | import org.onlab.onos.net.Description; | 3 | import org.onlab.onos.net.Description; |
| 4 | import org.onlab.onos.net.Device; | 4 | import org.onlab.onos.net.Device; |
| 5 | +import org.onlab.packet.ChassisId; | ||
| 5 | 6 | ||
| 6 | import java.net.URI; | 7 | import java.net.URI; |
| 7 | 8 | ||
| ... | @@ -54,4 +55,11 @@ public interface DeviceDescription extends Description { | ... | @@ -54,4 +55,11 @@ public interface DeviceDescription extends Description { |
| 54 | */ | 55 | */ |
| 55 | String serialNumber(); | 56 | String serialNumber(); |
| 56 | 57 | ||
| 58 | + /** | ||
| 59 | + * Returns a device chassis id. | ||
| 60 | + * | ||
| 61 | + * @return chassis id | ||
| 62 | + */ | ||
| 63 | + ChassisId chassisId(); | ||
| 64 | + | ||
| 57 | } | 65 | } | ... | ... |
| ... | @@ -3,6 +3,7 @@ package org.onlab.onos.net; | ... | @@ -3,6 +3,7 @@ package org.onlab.onos.net; |
| 3 | import com.google.common.testing.EqualsTester; | 3 | import com.google.common.testing.EqualsTester; |
| 4 | import org.junit.Test; | 4 | import org.junit.Test; |
| 5 | import org.onlab.onos.net.provider.ProviderId; | 5 | import org.onlab.onos.net.provider.ProviderId; |
| 6 | +import org.onlab.packet.ChassisId; | ||
| 6 | 7 | ||
| 7 | import static org.junit.Assert.assertEquals; | 8 | import static org.junit.Assert.assertEquals; |
| 8 | import static org.onlab.onos.net.Device.Type.SWITCH; | 9 | import static org.onlab.onos.net.Device.Type.SWITCH; |
| ... | @@ -21,14 +22,15 @@ public class DefaultDeviceTest { | ... | @@ -21,14 +22,15 @@ public class DefaultDeviceTest { |
| 21 | static final String SW = "3.9.1"; | 22 | static final String SW = "3.9.1"; |
| 22 | static final String SN1 = "43311-12345"; | 23 | static final String SN1 = "43311-12345"; |
| 23 | static final String SN2 = "42346-43512"; | 24 | static final String SN2 = "42346-43512"; |
| 25 | + static final ChassisId CID = new ChassisId(); | ||
| 24 | 26 | ||
| 25 | @Test | 27 | @Test |
| 26 | public void testEquality() { | 28 | public void testEquality() { |
| 27 | - Device d1 = new DefaultDevice(PID, DID1, SWITCH, MFR, HW, SW, SN1); | 29 | + Device d1 = new DefaultDevice(PID, DID1, SWITCH, MFR, HW, SW, SN1, CID); |
| 28 | - Device d2 = new DefaultDevice(PID, DID1, SWITCH, MFR, HW, SW, SN1); | 30 | + Device d2 = new DefaultDevice(PID, DID1, SWITCH, MFR, HW, SW, SN1, CID); |
| 29 | - Device d3 = new DefaultDevice(PID, DID2, SWITCH, MFR, HW, SW, SN2); | 31 | + Device d3 = new DefaultDevice(PID, DID2, SWITCH, MFR, HW, SW, SN2, CID); |
| 30 | - Device d4 = new DefaultDevice(PID, DID2, SWITCH, MFR, HW, SW, SN2); | 32 | + Device d4 = new DefaultDevice(PID, DID2, SWITCH, MFR, HW, SW, SN2, CID); |
| 31 | - Device d5 = new DefaultDevice(PID, DID2, SWITCH, MFR, HW, SW, SN1); | 33 | + Device d5 = new DefaultDevice(PID, DID2, SWITCH, MFR, HW, SW, SN1, CID); |
| 32 | 34 | ||
| 33 | new EqualsTester().addEqualityGroup(d1, d2) | 35 | new EqualsTester().addEqualityGroup(d1, d2) |
| 34 | .addEqualityGroup(d3, d4) | 36 | .addEqualityGroup(d3, d4) |
| ... | @@ -38,13 +40,13 @@ public class DefaultDeviceTest { | ... | @@ -38,13 +40,13 @@ public class DefaultDeviceTest { |
| 38 | 40 | ||
| 39 | @Test | 41 | @Test |
| 40 | public void basics() { | 42 | public void basics() { |
| 41 | - Device device = new DefaultDevice(PID, DID1, SWITCH, MFR, HW, SW, SN1); | 43 | + Device device = new DefaultDevice(PID, DID1, SWITCH, MFR, HW, SW, SN1, CID); |
| 42 | validate(device); | 44 | validate(device); |
| 43 | } | 45 | } |
| 44 | 46 | ||
| 45 | @Test | 47 | @Test |
| 46 | public void annotations() { | 48 | public void annotations() { |
| 47 | - Device device = new DefaultDevice(PID, DID1, SWITCH, MFR, HW, SW, SN1, | 49 | + Device device = new DefaultDevice(PID, DID1, SWITCH, MFR, HW, SW, SN1, CID, |
| 48 | DefaultAnnotations.builder().set("foo", "bar").build()); | 50 | DefaultAnnotations.builder().set("foo", "bar").build()); |
| 49 | validate(device); | 51 | validate(device); |
| 50 | assertEquals("incorrect provider", "bar", device.annotations().value("foo")); | 52 | assertEquals("incorrect provider", "bar", device.annotations().value("foo")); | ... | ... |
| ... | @@ -3,6 +3,7 @@ package org.onlab.onos.net; | ... | @@ -3,6 +3,7 @@ package org.onlab.onos.net; |
| 3 | import com.google.common.testing.EqualsTester; | 3 | import com.google.common.testing.EqualsTester; |
| 4 | import org.junit.Test; | 4 | import org.junit.Test; |
| 5 | import org.onlab.onos.net.provider.ProviderId; | 5 | import org.onlab.onos.net.provider.ProviderId; |
| 6 | +import org.onlab.packet.ChassisId; | ||
| 6 | 7 | ||
| 7 | import static org.junit.Assert.assertEquals; | 8 | import static org.junit.Assert.assertEquals; |
| 8 | import static org.onlab.onos.net.Device.Type.SWITCH; | 9 | import static org.onlab.onos.net.Device.Type.SWITCH; |
| ... | @@ -22,7 +23,8 @@ public class DefaultPortTest { | ... | @@ -22,7 +23,8 @@ public class DefaultPortTest { |
| 22 | 23 | ||
| 23 | @Test | 24 | @Test |
| 24 | public void testEquality() { | 25 | public void testEquality() { |
| 25 | - Device device = new DefaultDevice(PID, DID1, SWITCH, "m", "h", "s", "n"); | 26 | + Device device = new DefaultDevice(PID, DID1, SWITCH, "m", "h", "s", "n", |
| 27 | + new ChassisId()); | ||
| 26 | Port p1 = new DefaultPort(device, portNumber(1), true); | 28 | Port p1 = new DefaultPort(device, portNumber(1), true); |
| 27 | Port p2 = new DefaultPort(device, portNumber(1), true); | 29 | Port p2 = new DefaultPort(device, portNumber(1), true); |
| 28 | Port p3 = new DefaultPort(device, portNumber(2), true); | 30 | Port p3 = new DefaultPort(device, portNumber(2), true); |
| ... | @@ -37,7 +39,8 @@ public class DefaultPortTest { | ... | @@ -37,7 +39,8 @@ public class DefaultPortTest { |
| 37 | 39 | ||
| 38 | @Test | 40 | @Test |
| 39 | public void basics() { | 41 | public void basics() { |
| 40 | - Device device = new DefaultDevice(PID, DID1, SWITCH, "m", "h", "s", "n"); | 42 | + Device device = new DefaultDevice(PID, DID1, SWITCH, "m", "h", "s", "n", |
| 43 | + new ChassisId()); | ||
| 41 | Port port = new DefaultPort(device, portNumber(1), true); | 44 | Port port = new DefaultPort(device, portNumber(1), true); |
| 42 | assertEquals("incorrect element", device, port.element()); | 45 | assertEquals("incorrect element", device, port.element()); |
| 43 | assertEquals("incorrect number", portNumber(1), port.number()); | 46 | assertEquals("incorrect number", portNumber(1), port.number()); | ... | ... |
| 1 | package org.onlab.onos.net; | 1 | package org.onlab.onos.net; |
| 2 | 2 | ||
| 3 | import org.onlab.onos.net.provider.ProviderId; | 3 | import org.onlab.onos.net.provider.ProviderId; |
| 4 | +import org.onlab.packet.ChassisId; | ||
| 4 | import org.onlab.packet.IpPrefix; | 5 | import org.onlab.packet.IpPrefix; |
| 5 | 6 | ||
| 6 | import java.util.ArrayList; | 7 | import java.util.ArrayList; |
| ... | @@ -37,7 +38,7 @@ public final class NetTestTools { | ... | @@ -37,7 +38,7 @@ public final class NetTestTools { |
| 37 | // Crates a new device with the specified id | 38 | // Crates a new device with the specified id |
| 38 | public static Device device(String id) { | 39 | public static Device device(String id) { |
| 39 | return new DefaultDevice(PID, did(id), Device.Type.SWITCH, | 40 | return new DefaultDevice(PID, did(id), Device.Type.SWITCH, |
| 40 | - "mfg", "1.0", "1.1", "1234"); | 41 | + "mfg", "1.0", "1.1", "1234", new ChassisId()); |
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | // Crates a new host with the specified id | 44 | // Crates a new host with the specified id | ... | ... |
| 1 | package org.onlab.onos.net.device; | 1 | package org.onlab.onos.net.device; |
| 2 | 2 | ||
| 3 | import org.junit.Test; | 3 | import org.junit.Test; |
| 4 | +import org.onlab.packet.ChassisId; | ||
| 4 | 5 | ||
| 5 | import java.net.URI; | 6 | import java.net.URI; |
| 6 | 7 | ||
| ... | @@ -18,12 +19,13 @@ public class DefaultDeviceDescriptionTest { | ... | @@ -18,12 +19,13 @@ public class DefaultDeviceDescriptionTest { |
| 18 | private static final String HW = "1.1.x"; | 19 | private static final String HW = "1.1.x"; |
| 19 | private static final String SW = "3.9.1"; | 20 | private static final String SW = "3.9.1"; |
| 20 | private static final String SN = "43311-12345"; | 21 | private static final String SN = "43311-12345"; |
| 22 | + private static final ChassisId CID = new ChassisId(); | ||
| 21 | 23 | ||
| 22 | 24 | ||
| 23 | @Test | 25 | @Test |
| 24 | public void basics() { | 26 | public void basics() { |
| 25 | DeviceDescription device = | 27 | DeviceDescription device = |
| 26 | - new DefaultDeviceDescription(DURI, SWITCH, MFR, HW, SW, SN); | 28 | + new DefaultDeviceDescription(DURI, SWITCH, MFR, HW, SW, SN, CID); |
| 27 | assertEquals("incorrect uri", DURI, device.deviceURI()); | 29 | assertEquals("incorrect uri", DURI, device.deviceURI()); |
| 28 | assertEquals("incorrect type", SWITCH, device.type()); | 30 | assertEquals("incorrect type", SWITCH, device.type()); |
| 29 | assertEquals("incorrect manufacturer", MFR, device.manufacturer()); | 31 | assertEquals("incorrect manufacturer", MFR, device.manufacturer()); |
| ... | @@ -31,6 +33,7 @@ public class DefaultDeviceDescriptionTest { | ... | @@ -31,6 +33,7 @@ public class DefaultDeviceDescriptionTest { |
| 31 | assertEquals("incorrect sw", SW, device.swVersion()); | 33 | assertEquals("incorrect sw", SW, device.swVersion()); |
| 32 | assertEquals("incorrect serial", SN, device.serialNumber()); | 34 | assertEquals("incorrect serial", SN, device.serialNumber()); |
| 33 | assertTrue("incorrect toString", device.toString().contains("uri=of:foo")); | 35 | assertTrue("incorrect toString", device.toString().contains("uri=of:foo")); |
| 36 | + assertTrue("Incorrect chassis", device.chassisId().value() == 0); | ||
| 34 | } | 37 | } |
| 35 | 38 | ||
| 36 | } | 39 | } | ... | ... |
| ... | @@ -11,6 +11,7 @@ import org.onlab.onos.net.Device; | ... | @@ -11,6 +11,7 @@ import org.onlab.onos.net.Device; |
| 11 | import org.onlab.onos.net.Port; | 11 | import org.onlab.onos.net.Port; |
| 12 | import org.onlab.onos.net.PortNumber; | 12 | import org.onlab.onos.net.PortNumber; |
| 13 | import org.onlab.onos.net.provider.ProviderId; | 13 | import org.onlab.onos.net.provider.ProviderId; |
| 14 | +import org.onlab.packet.ChassisId; | ||
| 14 | 15 | ||
| 15 | /** | 16 | /** |
| 16 | * Tests of the device event. | 17 | * Tests of the device event. |
| ... | @@ -19,7 +20,7 @@ public class DeviceEventTest extends AbstractEventTest { | ... | @@ -19,7 +20,7 @@ public class DeviceEventTest extends AbstractEventTest { |
| 19 | 20 | ||
| 20 | private Device createDevice() { | 21 | private Device createDevice() { |
| 21 | return new DefaultDevice(new ProviderId("of", "foo"), deviceId("of:foo"), | 22 | return new DefaultDevice(new ProviderId("of", "foo"), deviceId("of:foo"), |
| 22 | - Device.Type.SWITCH, "box", "hw", "sw", "sn"); | 23 | + Device.Type.SWITCH, "box", "hw", "sw", "sn", new ChassisId()); |
| 23 | } | 24 | } |
| 24 | 25 | ||
| 25 | @Override | 26 | @Override | ... | ... |
| ... | @@ -18,9 +18,9 @@ public class DefaultGraphDescriptionTest { | ... | @@ -18,9 +18,9 @@ public class DefaultGraphDescriptionTest { |
| 18 | 18 | ||
| 19 | private static final DeviceId D3 = deviceId("3"); | 19 | private static final DeviceId D3 = deviceId("3"); |
| 20 | 20 | ||
| 21 | - static final Device DEV1 = new DefaultDevice(PID, D1, SWITCH, "", "", "", ""); | 21 | + static final Device DEV1 = new DefaultDevice(PID, D1, SWITCH, "", "", "", "", null); |
| 22 | - static final Device DEV2 = new DefaultDevice(PID, D2, SWITCH, "", "", "", ""); | 22 | + static final Device DEV2 = new DefaultDevice(PID, D2, SWITCH, "", "", "", "", null); |
| 23 | - static final Device DEV3 = new DefaultDevice(PID, D3, SWITCH, "", "", "", ""); | 23 | + static final Device DEV3 = new DefaultDevice(PID, D3, SWITCH, "", "", "", "", null); |
| 24 | 24 | ||
| 25 | @Test | 25 | @Test |
| 26 | public void basics() { | 26 | public void basics() { | ... | ... |
| ... | @@ -346,7 +346,7 @@ public class DeviceManager | ... | @@ -346,7 +346,7 @@ public class DeviceManager |
| 346 | new DefaultDeviceDescription( | 346 | new DefaultDeviceDescription( |
| 347 | did.uri(), device.type(), device.manufacturer(), | 347 | did.uri(), device.type(), device.manufacturer(), |
| 348 | device.hwVersion(), device.swVersion(), | 348 | device.hwVersion(), device.swVersion(), |
| 349 | - device.serialNumber())); | 349 | + device.serialNumber(), device.chassisId())); |
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | applyRole(did, MastershipRole.MASTER); | 352 | applyRole(did, MastershipRole.MASTER); | ... | ... |
| ... | @@ -96,7 +96,7 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> { | ... | @@ -96,7 +96,7 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> { |
| 96 | 96 | ||
| 97 | FlowRule rule = new DefaultFlowRule(link.src().deviceId(), | 97 | FlowRule rule = new DefaultFlowRule(link.src().deviceId(), |
| 98 | builder.build(), treatment, | 98 | builder.build(), treatment, |
| 99 | - 123, appId, 600); | 99 | + 123, appId, 15); |
| 100 | rules.add(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule)); | 100 | rules.add(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule)); |
| 101 | prev = link.dst(); | 101 | prev = link.dst(); |
| 102 | } | 102 | } | ... | ... |
| ... | @@ -37,6 +37,7 @@ import org.onlab.onos.net.device.PortDescription; | ... | @@ -37,6 +37,7 @@ import org.onlab.onos.net.device.PortDescription; |
| 37 | import org.onlab.onos.net.provider.AbstractProvider; | 37 | import org.onlab.onos.net.provider.AbstractProvider; |
| 38 | import org.onlab.onos.net.provider.ProviderId; | 38 | import org.onlab.onos.net.provider.ProviderId; |
| 39 | import org.onlab.onos.store.trivial.impl.SimpleDeviceStore; | 39 | import org.onlab.onos.store.trivial.impl.SimpleDeviceStore; |
| 40 | +import org.onlab.packet.ChassisId; | ||
| 40 | import org.onlab.packet.IpPrefix; | 41 | import org.onlab.packet.IpPrefix; |
| 41 | 42 | ||
| 42 | import java.util.ArrayList; | 43 | import java.util.ArrayList; |
| ... | @@ -62,6 +63,7 @@ public class DeviceManagerTest { | ... | @@ -62,6 +63,7 @@ public class DeviceManagerTest { |
| 62 | private static final String SW1 = "3.8.1"; | 63 | private static final String SW1 = "3.8.1"; |
| 63 | private static final String SW2 = "3.9.5"; | 64 | private static final String SW2 = "3.9.5"; |
| 64 | private static final String SN = "43311-12345"; | 65 | private static final String SN = "43311-12345"; |
| 66 | + private static final ChassisId CID = new ChassisId(); | ||
| 65 | 67 | ||
| 66 | private static final PortNumber P1 = PortNumber.portNumber(1); | 68 | private static final PortNumber P1 = PortNumber.portNumber(1); |
| 67 | private static final PortNumber P2 = PortNumber.portNumber(2); | 69 | private static final PortNumber P2 = PortNumber.portNumber(2); |
| ... | @@ -111,7 +113,7 @@ public class DeviceManagerTest { | ... | @@ -111,7 +113,7 @@ public class DeviceManagerTest { |
| 111 | private void connectDevice(DeviceId deviceId, String swVersion) { | 113 | private void connectDevice(DeviceId deviceId, String swVersion) { |
| 112 | DeviceDescription description = | 114 | DeviceDescription description = |
| 113 | new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, | 115 | new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, |
| 114 | - HW, swVersion, SN); | 116 | + HW, swVersion, SN, CID); |
| 115 | providerService.deviceConnected(deviceId, description); | 117 | providerService.deviceConnected(deviceId, description); |
| 116 | assertNotNull("device should be found", service.getDevice(DID1)); | 118 | assertNotNull("device should be found", service.getDevice(DID1)); |
| 117 | } | 119 | } | ... | ... |
| ... | @@ -68,7 +68,7 @@ public class FlowRuleManagerTest { | ... | @@ -68,7 +68,7 @@ public class FlowRuleManagerTest { |
| 68 | private static final DeviceId DID = DeviceId.deviceId("of:001"); | 68 | private static final DeviceId DID = DeviceId.deviceId("of:001"); |
| 69 | private static final int TIMEOUT = 10; | 69 | private static final int TIMEOUT = 10; |
| 70 | private static final Device DEV = new DefaultDevice( | 70 | private static final Device DEV = new DefaultDevice( |
| 71 | - PID, DID, Type.SWITCH, "", "", "", ""); | 71 | + PID, DID, Type.SWITCH, "", "", "", "", null); |
| 72 | 72 | ||
| 73 | private FlowRuleManager mgr; | 73 | private FlowRuleManager mgr; |
| 74 | 74 | ||
| ... | @@ -407,7 +407,6 @@ public class FlowRuleManagerTest { | ... | @@ -407,7 +407,6 @@ public class FlowRuleManagerTest { |
| 407 | FlowEntryState.PENDING_ADD)); | 407 | FlowEntryState.PENDING_ADD)); |
| 408 | 408 | ||
| 409 | 409 | ||
| 410 | - | ||
| 411 | } | 410 | } |
| 412 | 411 | ||
| 413 | 412 | ... | ... |
| ... | @@ -41,6 +41,7 @@ import org.onlab.onos.store.cluster.messaging.MessageSubject; | ... | @@ -41,6 +41,7 @@ import org.onlab.onos.store.cluster.messaging.MessageSubject; |
| 41 | import org.onlab.onos.store.common.impl.Timestamped; | 41 | import org.onlab.onos.store.common.impl.Timestamped; |
| 42 | import org.onlab.onos.store.serializers.KryoSerializer; | 42 | import org.onlab.onos.store.serializers.KryoSerializer; |
| 43 | import org.onlab.onos.store.serializers.DistributedStoreSerializers; | 43 | import org.onlab.onos.store.serializers.DistributedStoreSerializers; |
| 44 | +import org.onlab.packet.ChassisId; | ||
| 44 | import org.onlab.util.KryoPool; | 45 | import org.onlab.util.KryoPool; |
| 45 | import org.onlab.util.NewConcurrentHashMap; | 46 | import org.onlab.util.NewConcurrentHashMap; |
| 46 | import org.slf4j.Logger; | 47 | import org.slf4j.Logger; |
| ... | @@ -745,6 +746,7 @@ public class GossipDeviceStore | ... | @@ -745,6 +746,7 @@ public class GossipDeviceStore |
| 745 | String hwVersion = base.hwVersion(); | 746 | String hwVersion = base.hwVersion(); |
| 746 | String swVersion = base.swVersion(); | 747 | String swVersion = base.swVersion(); |
| 747 | String serialNumber = base.serialNumber(); | 748 | String serialNumber = base.serialNumber(); |
| 749 | + ChassisId chassisId = base.chassisId(); | ||
| 748 | DefaultAnnotations annotations = DefaultAnnotations.builder().build(); | 750 | DefaultAnnotations annotations = DefaultAnnotations.builder().build(); |
| 749 | annotations = merge(annotations, base.annotations()); | 751 | annotations = merge(annotations, base.annotations()); |
| 750 | 752 | ||
| ... | @@ -762,7 +764,8 @@ public class GossipDeviceStore | ... | @@ -762,7 +764,8 @@ public class GossipDeviceStore |
| 762 | } | 764 | } |
| 763 | 765 | ||
| 764 | return new DefaultDevice(primary, deviceId , type, manufacturer, | 766 | return new DefaultDevice(primary, deviceId , type, manufacturer, |
| 765 | - hwVersion, swVersion, serialNumber, annotations); | 767 | + hwVersion, swVersion, serialNumber, |
| 768 | + chassisId, annotations); | ||
| 766 | } | 769 | } |
| 767 | 770 | ||
| 768 | /** | 771 | /** | ... | ... |
| ... | @@ -53,6 +53,7 @@ import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService; | ... | @@ -53,6 +53,7 @@ import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService; |
| 53 | import org.onlab.onos.store.cluster.messaging.ClusterMessage; | 53 | import org.onlab.onos.store.cluster.messaging.ClusterMessage; |
| 54 | import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler; | 54 | import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler; |
| 55 | import org.onlab.onos.store.cluster.messaging.MessageSubject; | 55 | import org.onlab.onos.store.cluster.messaging.MessageSubject; |
| 56 | +import org.onlab.packet.ChassisId; | ||
| 56 | import org.onlab.packet.IpPrefix; | 57 | import org.onlab.packet.IpPrefix; |
| 57 | 58 | ||
| 58 | import com.google.common.collect.Iterables; | 59 | import com.google.common.collect.Iterables; |
| ... | @@ -74,6 +75,7 @@ public class GossipDeviceStoreTest { | ... | @@ -74,6 +75,7 @@ public class GossipDeviceStoreTest { |
| 74 | private static final String SW1 = "3.8.1"; | 75 | private static final String SW1 = "3.8.1"; |
| 75 | private static final String SW2 = "3.9.5"; | 76 | private static final String SW2 = "3.9.5"; |
| 76 | private static final String SN = "43311-12345"; | 77 | private static final String SN = "43311-12345"; |
| 78 | + private static final ChassisId CID = new ChassisId(); | ||
| 77 | 79 | ||
| 78 | private static final PortNumber P1 = PortNumber.portNumber(1); | 80 | private static final PortNumber P1 = PortNumber.portNumber(1); |
| 79 | private static final PortNumber P2 = PortNumber.portNumber(2); | 81 | private static final PortNumber P2 = PortNumber.portNumber(2); |
| ... | @@ -158,7 +160,7 @@ public class GossipDeviceStoreTest { | ... | @@ -158,7 +160,7 @@ public class GossipDeviceStoreTest { |
| 158 | SparseAnnotations... annotations) { | 160 | SparseAnnotations... annotations) { |
| 159 | DeviceDescription description = | 161 | DeviceDescription description = |
| 160 | new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, | 162 | new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, |
| 161 | - HW, swVersion, SN, annotations); | 163 | + HW, swVersion, SN, CID, annotations); |
| 162 | reset(clusterCommunicator); | 164 | reset(clusterCommunicator); |
| 163 | try { | 165 | try { |
| 164 | expect(clusterCommunicator.broadcast(anyObject(ClusterMessage.class))) | 166 | expect(clusterCommunicator.broadcast(anyObject(ClusterMessage.class))) |
| ... | @@ -175,7 +177,7 @@ public class GossipDeviceStoreTest { | ... | @@ -175,7 +177,7 @@ public class GossipDeviceStoreTest { |
| 175 | SparseAnnotations... annotations) { | 177 | SparseAnnotations... annotations) { |
| 176 | DeviceDescription description = | 178 | DeviceDescription description = |
| 177 | new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, | 179 | new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, |
| 178 | - HW, swVersion, SN, annotations); | 180 | + HW, swVersion, SN, CID, annotations); |
| 179 | deviceStore.createOrUpdateDevice(PIDA, deviceId, description); | 181 | deviceStore.createOrUpdateDevice(PIDA, deviceId, description); |
| 180 | } | 182 | } |
| 181 | 183 | ||
| ... | @@ -315,7 +317,7 @@ public class GossipDeviceStoreTest { | ... | @@ -315,7 +317,7 @@ public class GossipDeviceStoreTest { |
| 315 | public final void testCreateOrUpdateDevice() throws IOException { | 317 | public final void testCreateOrUpdateDevice() throws IOException { |
| 316 | DeviceDescription description = | 318 | DeviceDescription description = |
| 317 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 319 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 318 | - HW, SW1, SN); | 320 | + HW, SW1, SN, CID); |
| 319 | Capture<ClusterMessage> bcast = new Capture<>(); | 321 | Capture<ClusterMessage> bcast = new Capture<>(); |
| 320 | 322 | ||
| 321 | resetCommunicatorExpectingSingleBroadcast(bcast); | 323 | resetCommunicatorExpectingSingleBroadcast(bcast); |
| ... | @@ -328,7 +330,7 @@ public class GossipDeviceStoreTest { | ... | @@ -328,7 +330,7 @@ public class GossipDeviceStoreTest { |
| 328 | 330 | ||
| 329 | DeviceDescription description2 = | 331 | DeviceDescription description2 = |
| 330 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 332 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 331 | - HW, SW2, SN); | 333 | + HW, SW2, SN, CID); |
| 332 | resetCommunicatorExpectingSingleBroadcast(bcast); | 334 | resetCommunicatorExpectingSingleBroadcast(bcast); |
| 333 | DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2); | 335 | DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2); |
| 334 | assertEquals(DEVICE_UPDATED, event2.type()); | 336 | assertEquals(DEVICE_UPDATED, event2.type()); |
| ... | @@ -346,7 +348,7 @@ public class GossipDeviceStoreTest { | ... | @@ -346,7 +348,7 @@ public class GossipDeviceStoreTest { |
| 346 | // add | 348 | // add |
| 347 | DeviceDescription description = | 349 | DeviceDescription description = |
| 348 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 350 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 349 | - HW, SW1, SN, A2); | 351 | + HW, SW1, SN, CID, A2); |
| 350 | Capture<ClusterMessage> bcast = new Capture<>(); | 352 | Capture<ClusterMessage> bcast = new Capture<>(); |
| 351 | 353 | ||
| 352 | resetCommunicatorExpectingSingleBroadcast(bcast); | 354 | resetCommunicatorExpectingSingleBroadcast(bcast); |
| ... | @@ -362,7 +364,7 @@ public class GossipDeviceStoreTest { | ... | @@ -362,7 +364,7 @@ public class GossipDeviceStoreTest { |
| 362 | // update from primary | 364 | // update from primary |
| 363 | DeviceDescription description2 = | 365 | DeviceDescription description2 = |
| 364 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 366 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 365 | - HW, SW2, SN, A1); | 367 | + HW, SW2, SN, CID, A1); |
| 366 | resetCommunicatorExpectingSingleBroadcast(bcast); | 368 | resetCommunicatorExpectingSingleBroadcast(bcast); |
| 367 | 369 | ||
| 368 | DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2); | 370 | DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2); |
| ... | @@ -392,7 +394,7 @@ public class GossipDeviceStoreTest { | ... | @@ -392,7 +394,7 @@ public class GossipDeviceStoreTest { |
| 392 | // But, Ancillary annotations will be in effect | 394 | // But, Ancillary annotations will be in effect |
| 393 | DeviceDescription description3 = | 395 | DeviceDescription description3 = |
| 394 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 396 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 395 | - HW, SW1, SN, A2_2); | 397 | + HW, SW1, SN, CID, A2_2); |
| 396 | resetCommunicatorExpectingSingleBroadcast(bcast); | 398 | resetCommunicatorExpectingSingleBroadcast(bcast); |
| 397 | 399 | ||
| 398 | DeviceEvent event3 = deviceStore.createOrUpdateDevice(PIDA, DID1, description3); | 400 | DeviceEvent event3 = deviceStore.createOrUpdateDevice(PIDA, DID1, description3); |
| ... | @@ -775,7 +777,7 @@ public class GossipDeviceStoreTest { | ... | @@ -775,7 +777,7 @@ public class GossipDeviceStoreTest { |
| 775 | 777 | ||
| 776 | DeviceDescription description = | 778 | DeviceDescription description = |
| 777 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 779 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 778 | - HW, SW1, SN); | 780 | + HW, SW1, SN, CID); |
| 779 | deviceStore.setDelegate(checkAdd); | 781 | deviceStore.setDelegate(checkAdd); |
| 780 | deviceStore.createOrUpdateDevice(PID, DID1, description); | 782 | deviceStore.createOrUpdateDevice(PID, DID1, description); |
| 781 | assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS)); | 783 | assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS)); |
| ... | @@ -783,7 +785,7 @@ public class GossipDeviceStoreTest { | ... | @@ -783,7 +785,7 @@ public class GossipDeviceStoreTest { |
| 783 | 785 | ||
| 784 | DeviceDescription description2 = | 786 | DeviceDescription description2 = |
| 785 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 787 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 786 | - HW, SW2, SN); | 788 | + HW, SW2, SN, CID); |
| 787 | deviceStore.unsetDelegate(checkAdd); | 789 | deviceStore.unsetDelegate(checkAdd); |
| 788 | deviceStore.setDelegate(checkUpdate); | 790 | deviceStore.setDelegate(checkUpdate); |
| 789 | deviceStore.createOrUpdateDevice(PID, DID1, description2); | 791 | deviceStore.createOrUpdateDevice(PID, DID1, description2); | ... | ... |
| ... | @@ -169,7 +169,7 @@ public class DistributedDeviceStore | ... | @@ -169,7 +169,7 @@ public class DistributedDeviceStore |
| 169 | DefaultDevice device = new DefaultDevice(providerId, deviceId, desc.type(), | 169 | DefaultDevice device = new DefaultDevice(providerId, deviceId, desc.type(), |
| 170 | desc.manufacturer(), | 170 | desc.manufacturer(), |
| 171 | desc.hwVersion(), desc.swVersion(), | 171 | desc.hwVersion(), desc.swVersion(), |
| 172 | - desc.serialNumber()); | 172 | + desc.serialNumber(), desc.chassisId()); |
| 173 | 173 | ||
| 174 | synchronized (this) { | 174 | synchronized (this) { |
| 175 | final byte[] deviceIdBytes = serialize(deviceId); | 175 | final byte[] deviceIdBytes = serialize(deviceId); |
| ... | @@ -193,7 +193,8 @@ public class DistributedDeviceStore | ... | @@ -193,7 +193,8 @@ public class DistributedDeviceStore |
| 193 | desc.manufacturer(), | 193 | desc.manufacturer(), |
| 194 | desc.hwVersion(), | 194 | desc.hwVersion(), |
| 195 | desc.swVersion(), | 195 | desc.swVersion(), |
| 196 | - desc.serialNumber()); | 196 | + desc.serialNumber(), |
| 197 | + desc.chassisId()); | ||
| 197 | synchronized (this) { | 198 | synchronized (this) { |
| 198 | final byte[] deviceIdBytes = serialize(device.id()); | 199 | final byte[] deviceIdBytes = serialize(device.id()); |
| 199 | rawDevices.put(deviceIdBytes, serialize(updated)); | 200 | rawDevices.put(deviceIdBytes, serialize(updated)); | ... | ... |
| ... | @@ -40,6 +40,7 @@ import com.google.common.collect.Iterables; | ... | @@ -40,6 +40,7 @@ import com.google.common.collect.Iterables; |
| 40 | import com.google.common.collect.Sets; | 40 | import com.google.common.collect.Sets; |
| 41 | import com.hazelcast.config.Config; | 41 | import com.hazelcast.config.Config; |
| 42 | import com.hazelcast.core.Hazelcast; | 42 | import com.hazelcast.core.Hazelcast; |
| 43 | +import org.onlab.packet.ChassisId; | ||
| 43 | 44 | ||
| 44 | /** | 45 | /** |
| 45 | * Test of the Hazelcast based distributed DeviceStore implementation. | 46 | * Test of the Hazelcast based distributed DeviceStore implementation. |
| ... | @@ -54,6 +55,7 @@ public class DistributedDeviceStoreTest { | ... | @@ -54,6 +55,7 @@ public class DistributedDeviceStoreTest { |
| 54 | private static final String SW1 = "3.8.1"; | 55 | private static final String SW1 = "3.8.1"; |
| 55 | private static final String SW2 = "3.9.5"; | 56 | private static final String SW2 = "3.9.5"; |
| 56 | private static final String SN = "43311-12345"; | 57 | private static final String SN = "43311-12345"; |
| 58 | + private static final ChassisId CID = new ChassisId(); | ||
| 57 | 59 | ||
| 58 | private static final PortNumber P1 = PortNumber.portNumber(1); | 60 | private static final PortNumber P1 = PortNumber.portNumber(1); |
| 59 | private static final PortNumber P2 = PortNumber.portNumber(2); | 61 | private static final PortNumber P2 = PortNumber.portNumber(2); |
| ... | @@ -95,7 +97,7 @@ public class DistributedDeviceStoreTest { | ... | @@ -95,7 +97,7 @@ public class DistributedDeviceStoreTest { |
| 95 | private void putDevice(DeviceId deviceId, String swVersion) { | 97 | private void putDevice(DeviceId deviceId, String swVersion) { |
| 96 | DeviceDescription description = | 98 | DeviceDescription description = |
| 97 | new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, | 99 | new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, |
| 98 | - HW, swVersion, SN); | 100 | + HW, swVersion, SN, CID); |
| 99 | deviceStore.createOrUpdateDevice(PID, deviceId, description); | 101 | deviceStore.createOrUpdateDevice(PID, deviceId, description); |
| 100 | } | 102 | } |
| 101 | 103 | ||
| ... | @@ -154,14 +156,14 @@ public class DistributedDeviceStoreTest { | ... | @@ -154,14 +156,14 @@ public class DistributedDeviceStoreTest { |
| 154 | public final void testCreateOrUpdateDevice() { | 156 | public final void testCreateOrUpdateDevice() { |
| 155 | DeviceDescription description = | 157 | DeviceDescription description = |
| 156 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 158 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 157 | - HW, SW1, SN); | 159 | + HW, SW1, SN, CID); |
| 158 | DeviceEvent event = deviceStore.createOrUpdateDevice(PID, DID1, description); | 160 | DeviceEvent event = deviceStore.createOrUpdateDevice(PID, DID1, description); |
| 159 | assertEquals(DEVICE_ADDED, event.type()); | 161 | assertEquals(DEVICE_ADDED, event.type()); |
| 160 | assertDevice(DID1, SW1, event.subject()); | 162 | assertDevice(DID1, SW1, event.subject()); |
| 161 | 163 | ||
| 162 | DeviceDescription description2 = | 164 | DeviceDescription description2 = |
| 163 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 165 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 164 | - HW, SW2, SN); | 166 | + HW, SW2, SN, CID); |
| 165 | DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2); | 167 | DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2); |
| 166 | assertEquals(DEVICE_UPDATED, event2.type()); | 168 | assertEquals(DEVICE_UPDATED, event2.type()); |
| 167 | assertDevice(DID1, SW2, event2.subject()); | 169 | assertDevice(DID1, SW2, event2.subject()); |
| ... | @@ -362,7 +364,7 @@ public class DistributedDeviceStoreTest { | ... | @@ -362,7 +364,7 @@ public class DistributedDeviceStoreTest { |
| 362 | 364 | ||
| 363 | DeviceDescription description = | 365 | DeviceDescription description = |
| 364 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 366 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 365 | - HW, SW1, SN); | 367 | + HW, SW1, SN, CID); |
| 366 | deviceStore.setDelegate(checkAdd); | 368 | deviceStore.setDelegate(checkAdd); |
| 367 | deviceStore.createOrUpdateDevice(PID, DID1, description); | 369 | deviceStore.createOrUpdateDevice(PID, DID1, description); |
| 368 | assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS)); | 370 | assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS)); |
| ... | @@ -370,7 +372,7 @@ public class DistributedDeviceStoreTest { | ... | @@ -370,7 +372,7 @@ public class DistributedDeviceStoreTest { |
| 370 | 372 | ||
| 371 | DeviceDescription description2 = | 373 | DeviceDescription description2 = |
| 372 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 374 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 373 | - HW, SW2, SN); | 375 | + HW, SW2, SN, CID); |
| 374 | deviceStore.unsetDelegate(checkAdd); | 376 | deviceStore.unsetDelegate(checkAdd); |
| 375 | deviceStore.setDelegate(checkUpdate); | 377 | deviceStore.setDelegate(checkUpdate); |
| 376 | deviceStore.createOrUpdateDevice(PID, DID1, description2); | 378 | deviceStore.createOrUpdateDevice(PID, DID1, description2); | ... | ... |
| ... | @@ -27,6 +27,7 @@ import org.onlab.onos.net.device.DefaultPortDescription; | ... | @@ -27,6 +27,7 @@ import org.onlab.onos.net.device.DefaultPortDescription; |
| 27 | import org.onlab.onos.net.link.DefaultLinkDescription; | 27 | import org.onlab.onos.net.link.DefaultLinkDescription; |
| 28 | import org.onlab.onos.net.provider.ProviderId; | 28 | import org.onlab.onos.net.provider.ProviderId; |
| 29 | import org.onlab.onos.store.Timestamp; | 29 | import org.onlab.onos.store.Timestamp; |
| 30 | +import org.onlab.packet.ChassisId; | ||
| 30 | import org.onlab.packet.IpAddress; | 31 | import org.onlab.packet.IpAddress; |
| 31 | import org.onlab.packet.IpPrefix; | 32 | import org.onlab.packet.IpPrefix; |
| 32 | import org.onlab.util.KryoPool; | 33 | import org.onlab.util.KryoPool; |
| ... | @@ -61,6 +62,7 @@ public final class KryoPoolUtil { | ... | @@ -61,6 +62,7 @@ public final class KryoPoolUtil { |
| 61 | // | 62 | // |
| 62 | ControllerNode.State.class, | 63 | ControllerNode.State.class, |
| 63 | Device.Type.class, | 64 | Device.Type.class, |
| 65 | + ChassisId.class, | ||
| 64 | DefaultAnnotations.class, | 66 | DefaultAnnotations.class, |
| 65 | DefaultControllerNode.class, | 67 | DefaultControllerNode.class, |
| 66 | DefaultDevice.class, | 68 | DefaultDevice.class, | ... | ... |
| ... | @@ -26,6 +26,7 @@ import org.onlab.onos.net.MastershipRole; | ... | @@ -26,6 +26,7 @@ import org.onlab.onos.net.MastershipRole; |
| 26 | import org.onlab.onos.net.PortNumber; | 26 | import org.onlab.onos.net.PortNumber; |
| 27 | import org.onlab.onos.net.SparseAnnotations; | 27 | import org.onlab.onos.net.SparseAnnotations; |
| 28 | import org.onlab.onos.net.provider.ProviderId; | 28 | import org.onlab.onos.net.provider.ProviderId; |
| 29 | +import org.onlab.packet.ChassisId; | ||
| 29 | import org.onlab.packet.IpAddress; | 30 | import org.onlab.packet.IpAddress; |
| 30 | import org.onlab.packet.IpPrefix; | 31 | import org.onlab.packet.IpPrefix; |
| 31 | import org.onlab.util.KryoPool; | 32 | import org.onlab.util.KryoPool; |
| ... | @@ -49,7 +50,9 @@ public class KryoSerializerTest { | ... | @@ -49,7 +50,9 @@ public class KryoSerializerTest { |
| 49 | private static final String SW1 = "3.8.1"; | 50 | private static final String SW1 = "3.8.1"; |
| 50 | private static final String SW2 = "3.9.5"; | 51 | private static final String SW2 = "3.9.5"; |
| 51 | private static final String SN = "43311-12345"; | 52 | private static final String SN = "43311-12345"; |
| 52 | - private static final Device DEV1 = new DefaultDevice(PID, DID1, Device.Type.SWITCH, MFR, HW, SW1, SN); | 53 | + private static final ChassisId CID = new ChassisId(); |
| 54 | + private static final Device DEV1 = new DefaultDevice(PID, DID1, Device.Type.SWITCH, MFR, HW, | ||
| 55 | + SW1, SN, CID); | ||
| 53 | private static final SparseAnnotations A1 = DefaultAnnotations.builder() | 56 | private static final SparseAnnotations A1 = DefaultAnnotations.builder() |
| 54 | .set("A1", "a1") | 57 | .set("A1", "a1") |
| 55 | .set("B1", "b1") | 58 | .set("B1", "b1") | ... | ... |
| ... | @@ -30,6 +30,7 @@ import org.onlab.onos.net.device.DeviceStoreDelegate; | ... | @@ -30,6 +30,7 @@ import org.onlab.onos.net.device.DeviceStoreDelegate; |
| 30 | import org.onlab.onos.net.device.PortDescription; | 30 | import org.onlab.onos.net.device.PortDescription; |
| 31 | import org.onlab.onos.net.provider.ProviderId; | 31 | import org.onlab.onos.net.provider.ProviderId; |
| 32 | import org.onlab.onos.store.AbstractStore; | 32 | import org.onlab.onos.store.AbstractStore; |
| 33 | +import org.onlab.packet.ChassisId; | ||
| 33 | import org.onlab.util.NewConcurrentHashMap; | 34 | import org.onlab.util.NewConcurrentHashMap; |
| 34 | import org.slf4j.Logger; | 35 | import org.slf4j.Logger; |
| 35 | 36 | ||
| ... | @@ -404,6 +405,7 @@ public class SimpleDeviceStore | ... | @@ -404,6 +405,7 @@ public class SimpleDeviceStore |
| 404 | String hwVersion = base.hwVersion(); | 405 | String hwVersion = base.hwVersion(); |
| 405 | String swVersion = base.swVersion(); | 406 | String swVersion = base.swVersion(); |
| 406 | String serialNumber = base.serialNumber(); | 407 | String serialNumber = base.serialNumber(); |
| 408 | + ChassisId chassisId = base.chassisId(); | ||
| 407 | DefaultAnnotations annotations = DefaultAnnotations.builder().build(); | 409 | DefaultAnnotations annotations = DefaultAnnotations.builder().build(); |
| 408 | annotations = merge(annotations, base.annotations()); | 410 | annotations = merge(annotations, base.annotations()); |
| 409 | 411 | ||
| ... | @@ -421,7 +423,8 @@ public class SimpleDeviceStore | ... | @@ -421,7 +423,8 @@ public class SimpleDeviceStore |
| 421 | } | 423 | } |
| 422 | 424 | ||
| 423 | return new DefaultDevice(primary, deviceId , type, manufacturer, | 425 | return new DefaultDevice(primary, deviceId , type, manufacturer, |
| 424 | - hwVersion, swVersion, serialNumber, annotations); | 426 | + hwVersion, swVersion, serialNumber, |
| 427 | + chassisId, annotations); | ||
| 425 | } | 428 | } |
| 426 | 429 | ||
| 427 | /** | 430 | /** | ... | ... |
| ... | @@ -17,6 +17,7 @@ import org.onlab.onos.net.topology.GraphDescription; | ... | @@ -17,6 +17,7 @@ import org.onlab.onos.net.topology.GraphDescription; |
| 17 | import org.onlab.onos.net.topology.LinkWeight; | 17 | import org.onlab.onos.net.topology.LinkWeight; |
| 18 | import org.onlab.onos.net.topology.TopologyCluster; | 18 | import org.onlab.onos.net.topology.TopologyCluster; |
| 19 | import org.onlab.onos.net.topology.TopologyEdge; | 19 | import org.onlab.onos.net.topology.TopologyEdge; |
| 20 | +import org.onlab.packet.ChassisId; | ||
| 20 | 21 | ||
| 21 | import java.util.Set; | 22 | import java.util.Set; |
| 22 | 23 | ||
| ... | @@ -119,7 +120,7 @@ public class DefaultTopologyTest { | ... | @@ -119,7 +120,7 @@ public class DefaultTopologyTest { |
| 119 | // Crates a new device with the specified id | 120 | // Crates a new device with the specified id |
| 120 | public static Device device(String id) { | 121 | public static Device device(String id) { |
| 121 | return new DefaultDevice(PID, did(id), Device.Type.SWITCH, | 122 | return new DefaultDevice(PID, did(id), Device.Type.SWITCH, |
| 122 | - "mfg", "1.0", "1.1", "1234"); | 123 | + "mfg", "1.0", "1.1", "1234", new ChassisId()); |
| 123 | } | 124 | } |
| 124 | 125 | ||
| 125 | // Short-hand for producing a device id from a string | 126 | // Short-hand for producing a device id from a string | ... | ... |
| ... | @@ -40,6 +40,7 @@ import org.onlab.onos.net.provider.ProviderId; | ... | @@ -40,6 +40,7 @@ import org.onlab.onos.net.provider.ProviderId; |
| 40 | 40 | ||
| 41 | import com.google.common.collect.Iterables; | 41 | import com.google.common.collect.Iterables; |
| 42 | import com.google.common.collect.Sets; | 42 | import com.google.common.collect.Sets; |
| 43 | +import org.onlab.packet.ChassisId; | ||
| 43 | 44 | ||
| 44 | /** | 45 | /** |
| 45 | * Test of the simple DeviceStore implementation. | 46 | * Test of the simple DeviceStore implementation. |
| ... | @@ -55,6 +56,7 @@ public class SimpleDeviceStoreTest { | ... | @@ -55,6 +56,7 @@ public class SimpleDeviceStoreTest { |
| 55 | private static final String SW1 = "3.8.1"; | 56 | private static final String SW1 = "3.8.1"; |
| 56 | private static final String SW2 = "3.9.5"; | 57 | private static final String SW2 = "3.9.5"; |
| 57 | private static final String SN = "43311-12345"; | 58 | private static final String SN = "43311-12345"; |
| 59 | + private static final ChassisId CID = new ChassisId(); | ||
| 58 | 60 | ||
| 59 | private static final PortNumber P1 = PortNumber.portNumber(1); | 61 | private static final PortNumber P1 = PortNumber.portNumber(1); |
| 60 | private static final PortNumber P2 = PortNumber.portNumber(2); | 62 | private static final PortNumber P2 = PortNumber.portNumber(2); |
| ... | @@ -107,7 +109,7 @@ public class SimpleDeviceStoreTest { | ... | @@ -107,7 +109,7 @@ public class SimpleDeviceStoreTest { |
| 107 | SparseAnnotations... annotations) { | 109 | SparseAnnotations... annotations) { |
| 108 | DeviceDescription description = | 110 | DeviceDescription description = |
| 109 | new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, | 111 | new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, |
| 110 | - HW, swVersion, SN, annotations); | 112 | + HW, swVersion, SN, CID, annotations); |
| 111 | deviceStore.createOrUpdateDevice(PID, deviceId, description); | 113 | deviceStore.createOrUpdateDevice(PID, deviceId, description); |
| 112 | } | 114 | } |
| 113 | 115 | ||
| ... | @@ -115,7 +117,7 @@ public class SimpleDeviceStoreTest { | ... | @@ -115,7 +117,7 @@ public class SimpleDeviceStoreTest { |
| 115 | SparseAnnotations... annotations) { | 117 | SparseAnnotations... annotations) { |
| 116 | DeviceDescription description = | 118 | DeviceDescription description = |
| 117 | new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, | 119 | new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, |
| 118 | - HW, swVersion, SN, annotations); | 120 | + HW, swVersion, SN, CID, annotations); |
| 119 | deviceStore.createOrUpdateDevice(PIDA, deviceId, description); | 121 | deviceStore.createOrUpdateDevice(PIDA, deviceId, description); |
| 120 | } | 122 | } |
| 121 | 123 | ||
| ... | @@ -193,14 +195,14 @@ public class SimpleDeviceStoreTest { | ... | @@ -193,14 +195,14 @@ public class SimpleDeviceStoreTest { |
| 193 | public final void testCreateOrUpdateDevice() { | 195 | public final void testCreateOrUpdateDevice() { |
| 194 | DeviceDescription description = | 196 | DeviceDescription description = |
| 195 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 197 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 196 | - HW, SW1, SN); | 198 | + HW, SW1, SN, CID); |
| 197 | DeviceEvent event = deviceStore.createOrUpdateDevice(PID, DID1, description); | 199 | DeviceEvent event = deviceStore.createOrUpdateDevice(PID, DID1, description); |
| 198 | assertEquals(DEVICE_ADDED, event.type()); | 200 | assertEquals(DEVICE_ADDED, event.type()); |
| 199 | assertDevice(DID1, SW1, event.subject()); | 201 | assertDevice(DID1, SW1, event.subject()); |
| 200 | 202 | ||
| 201 | DeviceDescription description2 = | 203 | DeviceDescription description2 = |
| 202 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 204 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 203 | - HW, SW2, SN); | 205 | + HW, SW2, SN, CID); |
| 204 | DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2); | 206 | DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2); |
| 205 | assertEquals(DEVICE_UPDATED, event2.type()); | 207 | assertEquals(DEVICE_UPDATED, event2.type()); |
| 206 | assertDevice(DID1, SW2, event2.subject()); | 208 | assertDevice(DID1, SW2, event2.subject()); |
| ... | @@ -212,7 +214,7 @@ public class SimpleDeviceStoreTest { | ... | @@ -212,7 +214,7 @@ public class SimpleDeviceStoreTest { |
| 212 | public final void testCreateOrUpdateDeviceAncillary() { | 214 | public final void testCreateOrUpdateDeviceAncillary() { |
| 213 | DeviceDescription description = | 215 | DeviceDescription description = |
| 214 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 216 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 215 | - HW, SW1, SN, A2); | 217 | + HW, SW1, SN, CID, A2); |
| 216 | DeviceEvent event = deviceStore.createOrUpdateDevice(PIDA, DID1, description); | 218 | DeviceEvent event = deviceStore.createOrUpdateDevice(PIDA, DID1, description); |
| 217 | assertEquals(DEVICE_ADDED, event.type()); | 219 | assertEquals(DEVICE_ADDED, event.type()); |
| 218 | assertDevice(DID1, SW1, event.subject()); | 220 | assertDevice(DID1, SW1, event.subject()); |
| ... | @@ -222,7 +224,7 @@ public class SimpleDeviceStoreTest { | ... | @@ -222,7 +224,7 @@ public class SimpleDeviceStoreTest { |
| 222 | 224 | ||
| 223 | DeviceDescription description2 = | 225 | DeviceDescription description2 = |
| 224 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 226 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 225 | - HW, SW2, SN, A1); | 227 | + HW, SW2, SN, CID, A1); |
| 226 | DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2); | 228 | DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2); |
| 227 | assertEquals(DEVICE_UPDATED, event2.type()); | 229 | assertEquals(DEVICE_UPDATED, event2.type()); |
| 228 | assertDevice(DID1, SW2, event2.subject()); | 230 | assertDevice(DID1, SW2, event2.subject()); |
| ... | @@ -238,7 +240,7 @@ public class SimpleDeviceStoreTest { | ... | @@ -238,7 +240,7 @@ public class SimpleDeviceStoreTest { |
| 238 | // But, Ancillary annotations will be in effect | 240 | // But, Ancillary annotations will be in effect |
| 239 | DeviceDescription description3 = | 241 | DeviceDescription description3 = |
| 240 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 242 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 241 | - HW, SW1, SN, A2_2); | 243 | + HW, SW1, SN, CID, A2_2); |
| 242 | DeviceEvent event3 = deviceStore.createOrUpdateDevice(PIDA, DID1, description3); | 244 | DeviceEvent event3 = deviceStore.createOrUpdateDevice(PIDA, DID1, description3); |
| 243 | assertEquals(DEVICE_UPDATED, event3.type()); | 245 | assertEquals(DEVICE_UPDATED, event3.type()); |
| 244 | // basic information will be the one from Primary | 246 | // basic information will be the one from Primary |
| ... | @@ -508,7 +510,7 @@ public class SimpleDeviceStoreTest { | ... | @@ -508,7 +510,7 @@ public class SimpleDeviceStoreTest { |
| 508 | 510 | ||
| 509 | DeviceDescription description = | 511 | DeviceDescription description = |
| 510 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 512 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 511 | - HW, SW1, SN); | 513 | + HW, SW1, SN, CID); |
| 512 | deviceStore.setDelegate(checkAdd); | 514 | deviceStore.setDelegate(checkAdd); |
| 513 | deviceStore.createOrUpdateDevice(PID, DID1, description); | 515 | deviceStore.createOrUpdateDevice(PID, DID1, description); |
| 514 | assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS)); | 516 | assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS)); |
| ... | @@ -516,7 +518,7 @@ public class SimpleDeviceStoreTest { | ... | @@ -516,7 +518,7 @@ public class SimpleDeviceStoreTest { |
| 516 | 518 | ||
| 517 | DeviceDescription description2 = | 519 | DeviceDescription description2 = |
| 518 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, | 520 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
| 519 | - HW, SW2, SN); | 521 | + HW, SW2, SN, CID); |
| 520 | deviceStore.unsetDelegate(checkAdd); | 522 | deviceStore.unsetDelegate(checkAdd); |
| 521 | deviceStore.setDelegate(checkUpdate); | 523 | deviceStore.setDelegate(checkUpdate); |
| 522 | deviceStore.createOrUpdateDevice(PID, DID1, description2); | 524 | deviceStore.createOrUpdateDevice(PID, DID1, description2); | ... | ... |
| ... | @@ -101,8 +101,8 @@ | ... | @@ -101,8 +101,8 @@ |
| 101 | <bundle>mvn:org.onlab.onos/onos-of-api/1.0.0-SNAPSHOT</bundle> | 101 | <bundle>mvn:org.onlab.onos/onos-of-api/1.0.0-SNAPSHOT</bundle> |
| 102 | <bundle>mvn:org.onlab.onos/onos-of-ctl/1.0.0-SNAPSHOT</bundle> | 102 | <bundle>mvn:org.onlab.onos/onos-of-ctl/1.0.0-SNAPSHOT</bundle> |
| 103 | 103 | ||
| 104 | + <bundle>mvn:org.onlab.onos/onos-lldp-provider/1.0.0-SNAPSHOT</bundle> | ||
| 104 | <bundle>mvn:org.onlab.onos/onos-of-provider-device/1.0.0-SNAPSHOT</bundle> | 105 | <bundle>mvn:org.onlab.onos/onos-of-provider-device/1.0.0-SNAPSHOT</bundle> |
| 105 | - <bundle>mvn:org.onlab.onos/onos-of-provider-link/1.0.0-SNAPSHOT</bundle> | ||
| 106 | <bundle>mvn:org.onlab.onos/onos-of-provider-host/1.0.0-SNAPSHOT</bundle> | 106 | <bundle>mvn:org.onlab.onos/onos-of-provider-host/1.0.0-SNAPSHOT</bundle> |
| 107 | <bundle>mvn:org.onlab.onos/onos-of-provider-packet/1.0.0-SNAPSHOT</bundle> | 107 | <bundle>mvn:org.onlab.onos/onos-of-provider-packet/1.0.0-SNAPSHOT</bundle> |
| 108 | <bundle>mvn:org.onlab.onos/onos-of-provider-flow/1.0.0-SNAPSHOT</bundle> | 108 | <bundle>mvn:org.onlab.onos/onos-of-provider-flow/1.0.0-SNAPSHOT</bundle> | ... | ... |
providers/lldp/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
| 5 | + <modelVersion>4.0.0</modelVersion> | ||
| 6 | + | ||
| 7 | + | ||
| 8 | + <parent> | ||
| 9 | + <groupId>org.onlab.onos</groupId> | ||
| 10 | + <artifactId>onos-providers</artifactId> | ||
| 11 | + <version>1.0.0-SNAPSHOT</version> | ||
| 12 | + <relativePath>../pom.xml</relativePath> | ||
| 13 | + </parent> | ||
| 14 | + | ||
| 15 | + <artifactId>onos-lldp-provider</artifactId> | ||
| 16 | + <packaging>bundle</packaging> | ||
| 17 | + | ||
| 18 | + <description>ONOS LLDP Link Discovery</description> | ||
| 19 | + | ||
| 20 | +</project> |
| 1 | +package org.onlab.onos.provider.lldp.impl; | ||
| 2 | + | ||
| 3 | +import org.apache.felix.scr.annotations.Activate; | ||
| 4 | +import org.apache.felix.scr.annotations.Component; | ||
| 5 | +import org.apache.felix.scr.annotations.Deactivate; | ||
| 6 | +import org.apache.felix.scr.annotations.Reference; | ||
| 7 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
| 8 | +import org.onlab.onos.net.ConnectPoint; | ||
| 9 | +import org.onlab.onos.net.Device; | ||
| 10 | +import org.onlab.onos.net.DeviceId; | ||
| 11 | +import org.onlab.onos.net.device.DeviceEvent; | ||
| 12 | +import org.onlab.onos.net.device.DeviceListener; | ||
| 13 | +import org.onlab.onos.net.device.DeviceService; | ||
| 14 | +import org.onlab.onos.net.link.LinkProvider; | ||
| 15 | +import org.onlab.onos.net.link.LinkProviderRegistry; | ||
| 16 | +import org.onlab.onos.net.link.LinkProviderService; | ||
| 17 | +import org.onlab.onos.net.packet.PacketContext; | ||
| 18 | +import org.onlab.onos.net.packet.PacketProcessor; | ||
| 19 | +import org.onlab.onos.net.packet.PacketService; | ||
| 20 | +import org.onlab.onos.net.provider.AbstractProvider; | ||
| 21 | +import org.onlab.onos.net.provider.ProviderId; | ||
| 22 | +import org.slf4j.Logger; | ||
| 23 | + | ||
| 24 | +import java.util.Map; | ||
| 25 | +import java.util.concurrent.ConcurrentHashMap; | ||
| 26 | + | ||
| 27 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 28 | + | ||
| 29 | + | ||
| 30 | +/** | ||
| 31 | + * Provider which uses an OpenFlow controller to detect network | ||
| 32 | + * infrastructure links. | ||
| 33 | + */ | ||
| 34 | +@Component(immediate = true) | ||
| 35 | +public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ||
| 36 | + | ||
| 37 | + private final Logger log = getLogger(getClass()); | ||
| 38 | + | ||
| 39 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 40 | + protected LinkProviderRegistry providerRegistry; | ||
| 41 | + | ||
| 42 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 43 | + protected DeviceService deviceService; | ||
| 44 | + | ||
| 45 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 46 | + protected PacketService packetSevice; | ||
| 47 | + | ||
| 48 | + private LinkProviderService providerService; | ||
| 49 | + | ||
| 50 | + private final boolean useBDDP = true; | ||
| 51 | + | ||
| 52 | + | ||
| 53 | + private final InternalLinkProvider listener = new InternalLinkProvider(); | ||
| 54 | + | ||
| 55 | + protected final Map<DeviceId, LinkDiscovery> discoverers = new ConcurrentHashMap<>(); | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * Creates an OpenFlow link provider. | ||
| 59 | + */ | ||
| 60 | + public LLDPLinkProvider() { | ||
| 61 | + super(new ProviderId("lldp", "org.onlab.onos.provider.lldp")); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @Activate | ||
| 65 | + public void activate() { | ||
| 66 | + providerService = providerRegistry.register(this); | ||
| 67 | + deviceService.addListener(listener); | ||
| 68 | + packetSevice.addProcessor(listener, 0); | ||
| 69 | + | ||
| 70 | + log.info("Started"); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + @Deactivate | ||
| 74 | + public void deactivate() { | ||
| 75 | + for (LinkDiscovery ld : discoverers.values()) { | ||
| 76 | + ld.stop(); | ||
| 77 | + } | ||
| 78 | + providerRegistry.unregister(this); | ||
| 79 | + deviceService.removeListener(listener); | ||
| 80 | + packetSevice.removeProcessor(listener); | ||
| 81 | + providerService = null; | ||
| 82 | + | ||
| 83 | + log.info("Stopped"); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + | ||
| 87 | + private class InternalLinkProvider implements PacketProcessor, DeviceListener { | ||
| 88 | + | ||
| 89 | + @Override | ||
| 90 | + public void event(DeviceEvent event) { | ||
| 91 | + LinkDiscovery ld = null; | ||
| 92 | + Device device = event.subject(); | ||
| 93 | + // it's not a switch so leave. | ||
| 94 | + if (device.type() != Device.Type.SWITCH) { | ||
| 95 | + return; | ||
| 96 | + } | ||
| 97 | + switch (event.type()) { | ||
| 98 | + case DEVICE_ADDED: | ||
| 99 | + discoverers.put(event.subject().id(), | ||
| 100 | + new LinkDiscovery(event.subject(), packetSevice, | ||
| 101 | + providerService, useBDDP)); | ||
| 102 | + break; | ||
| 103 | + case PORT_ADDED: | ||
| 104 | + case PORT_UPDATED: | ||
| 105 | + if (event.port().isEnabled()) { | ||
| 106 | + ld = discoverers.get(event.subject().id()); | ||
| 107 | + if (ld == null) { | ||
| 108 | + return; | ||
| 109 | + } | ||
| 110 | + ld.addPort(event.port()); | ||
| 111 | + } else { | ||
| 112 | + ConnectPoint point = new ConnectPoint(event.subject().id(), | ||
| 113 | + event.port().number()); | ||
| 114 | + providerService.linksVanished(point); | ||
| 115 | + } | ||
| 116 | + break; | ||
| 117 | + case PORT_REMOVED: | ||
| 118 | + ConnectPoint point = new ConnectPoint(event.subject().id(), | ||
| 119 | + event.port().number()); | ||
| 120 | + providerService.linksVanished(point); | ||
| 121 | + break; | ||
| 122 | + case DEVICE_REMOVED: | ||
| 123 | + case DEVICE_SUSPENDED: | ||
| 124 | + ld = discoverers.get(event.subject().id()); | ||
| 125 | + if (ld == null) { | ||
| 126 | + return; | ||
| 127 | + } | ||
| 128 | + ld.stop(); | ||
| 129 | + providerService.linksVanished(event.subject().id()); | ||
| 130 | + break; | ||
| 131 | + case DEVICE_AVAILABILITY_CHANGED: | ||
| 132 | + ld = discoverers.get(event.subject().id()); | ||
| 133 | + if (ld == null) { | ||
| 134 | + return; | ||
| 135 | + } | ||
| 136 | + if (deviceService.isAvailable(event.subject().id())) { | ||
| 137 | + ld.start(); | ||
| 138 | + } else { | ||
| 139 | + providerService.linksVanished(event.subject().id()); | ||
| 140 | + ld.stop(); | ||
| 141 | + } | ||
| 142 | + break; | ||
| 143 | + case DEVICE_UPDATED: | ||
| 144 | + case DEVICE_MASTERSHIP_CHANGED: | ||
| 145 | + break; | ||
| 146 | + default: | ||
| 147 | + log.debug("Unknown event {}", event); | ||
| 148 | + } | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + @Override | ||
| 152 | + public void process(PacketContext context) { | ||
| 153 | + LinkDiscovery ld = discoverers.get( | ||
| 154 | + context.inPacket().receivedFrom().deviceId()); | ||
| 155 | + if (ld == null) { | ||
| 156 | + return; | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + if (ld.handleLLDP(context)) { | ||
| 160 | + context.block(); | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | +} |
This diff is collapsed. Click to expand it.
| ... | @@ -23,6 +23,7 @@ import org.onlab.onos.openflow.controller.OpenFlowController; | ... | @@ -23,6 +23,7 @@ import org.onlab.onos.openflow.controller.OpenFlowController; |
| 23 | import org.onlab.onos.openflow.controller.OpenFlowSwitch; | 23 | import org.onlab.onos.openflow.controller.OpenFlowSwitch; |
| 24 | import org.onlab.onos.openflow.controller.OpenFlowSwitchListener; | 24 | import org.onlab.onos.openflow.controller.OpenFlowSwitchListener; |
| 25 | import org.onlab.onos.openflow.controller.RoleState; | 25 | import org.onlab.onos.openflow.controller.RoleState; |
| 26 | +import org.onlab.packet.ChassisId; | ||
| 26 | import org.projectfloodlight.openflow.protocol.OFPortConfig; | 27 | import org.projectfloodlight.openflow.protocol.OFPortConfig; |
| 27 | import org.projectfloodlight.openflow.protocol.OFPortDesc; | 28 | import org.projectfloodlight.openflow.protocol.OFPortDesc; |
| 28 | import org.projectfloodlight.openflow.protocol.OFPortState; | 29 | import org.projectfloodlight.openflow.protocol.OFPortState; |
| ... | @@ -117,13 +118,14 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -117,13 +118,14 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
| 117 | } | 118 | } |
| 118 | DeviceId did = deviceId(uri(dpid)); | 119 | DeviceId did = deviceId(uri(dpid)); |
| 119 | OpenFlowSwitch sw = controller.getSwitch(dpid); | 120 | OpenFlowSwitch sw = controller.getSwitch(dpid); |
| 120 | - | 121 | + ChassisId cId = new ChassisId(dpid.value()); |
| 121 | DeviceDescription description = | 122 | DeviceDescription description = |
| 122 | new DefaultDeviceDescription(did.uri(), Device.Type.SWITCH, | 123 | new DefaultDeviceDescription(did.uri(), Device.Type.SWITCH, |
| 123 | sw.manfacturerDescription(), | 124 | sw.manfacturerDescription(), |
| 124 | sw.hardwareDescription(), | 125 | sw.hardwareDescription(), |
| 125 | sw.softwareDescription(), | 126 | sw.softwareDescription(), |
| 126 | - sw.serialNumber()); | 127 | + sw.serialNumber(), |
| 128 | + cId); | ||
| 127 | providerService.deviceConnected(did, description); | 129 | providerService.deviceConnected(did, description); |
| 128 | providerService.updatePorts(did, buildPortDescriptions(sw.getPorts())); | 130 | providerService.updatePorts(did, buildPortDescriptions(sw.getPorts())); |
| 129 | } | 131 | } | ... | ... |
| ... | @@ -59,7 +59,7 @@ public class OpenFlowDeviceProviderTest { | ... | @@ -59,7 +59,7 @@ public class OpenFlowDeviceProviderTest { |
| 59 | private static final List<OFPortDesc> PLIST = Lists.newArrayList(PD1, PD2); | 59 | private static final List<OFPortDesc> PLIST = Lists.newArrayList(PD1, PD2); |
| 60 | 60 | ||
| 61 | private static final Device DEV1 = | 61 | private static final Device DEV1 = |
| 62 | - new DefaultDevice(PID, DID1, SWITCH, "", "", "", ""); | 62 | + new DefaultDevice(PID, DID1, SWITCH, "", "", "", "", null); |
| 63 | 63 | ||
| 64 | private static final TestOpenFlowSwitch SW1 = new TestOpenFlowSwitch(); | 64 | private static final TestOpenFlowSwitch SW1 = new TestOpenFlowSwitch(); |
| 65 | 65 | ... | ... |
providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/OpenFlowRuleProvider.java
| 1 | package org.onlab.onos.provider.of.flow.impl; | 1 | package org.onlab.onos.provider.of.flow.impl; |
| 2 | 2 | ||
| 3 | -import static org.slf4j.LoggerFactory.getLogger; | 3 | +import com.google.common.collect.ArrayListMultimap; |
| 4 | - | 4 | +import com.google.common.collect.Lists; |
| 5 | -import java.util.HashMap; | 5 | +import com.google.common.collect.Maps; |
| 6 | -import java.util.HashSet; | 6 | +import com.google.common.collect.Multimap; |
| 7 | -import java.util.List; | ||
| 8 | -import java.util.Map; | ||
| 9 | -import java.util.Set; | ||
| 10 | -import java.util.concurrent.ConcurrentHashMap; | ||
| 11 | -import java.util.concurrent.CountDownLatch; | ||
| 12 | -import java.util.concurrent.ExecutionException; | ||
| 13 | -import java.util.concurrent.Future; | ||
| 14 | -import java.util.concurrent.TimeUnit; | ||
| 15 | -import java.util.concurrent.TimeoutException; | ||
| 16 | -import java.util.concurrent.atomic.AtomicBoolean; | ||
| 17 | - | ||
| 18 | import org.apache.felix.scr.annotations.Activate; | 7 | import org.apache.felix.scr.annotations.Activate; |
| 19 | import org.apache.felix.scr.annotations.Component; | 8 | import org.apache.felix.scr.annotations.Component; |
| 20 | import org.apache.felix.scr.annotations.Deactivate; | 9 | import org.apache.felix.scr.annotations.Deactivate; |
| ... | @@ -68,10 +57,20 @@ import org.projectfloodlight.openflow.types.OFPort; | ... | @@ -68,10 +57,20 @@ import org.projectfloodlight.openflow.types.OFPort; |
| 68 | import org.projectfloodlight.openflow.types.U32; | 57 | import org.projectfloodlight.openflow.types.U32; |
| 69 | import org.slf4j.Logger; | 58 | import org.slf4j.Logger; |
| 70 | 59 | ||
| 71 | -import com.google.common.collect.ArrayListMultimap; | 60 | +import java.util.HashMap; |
| 72 | -import com.google.common.collect.Lists; | 61 | +import java.util.HashSet; |
| 73 | -import com.google.common.collect.Maps; | 62 | +import java.util.List; |
| 74 | -import com.google.common.collect.Multimap; | 63 | +import java.util.Map; |
| 64 | +import java.util.Set; | ||
| 65 | +import java.util.concurrent.ConcurrentHashMap; | ||
| 66 | +import java.util.concurrent.CountDownLatch; | ||
| 67 | +import java.util.concurrent.ExecutionException; | ||
| 68 | +import java.util.concurrent.Future; | ||
| 69 | +import java.util.concurrent.TimeUnit; | ||
| 70 | +import java.util.concurrent.TimeoutException; | ||
| 71 | +import java.util.concurrent.atomic.AtomicBoolean; | ||
| 72 | + | ||
| 73 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 75 | 74 | ||
| 76 | /** | 75 | /** |
| 77 | * Provider which uses an OpenFlow controller to detect network | 76 | * Provider which uses an OpenFlow controller to detect network |
| ... | @@ -166,6 +165,9 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -166,6 +165,9 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
| 166 | for (FlowRuleBatchEntry fbe : batch.getOperations()) { | 165 | for (FlowRuleBatchEntry fbe : batch.getOperations()) { |
| 167 | FlowRule flowRule = fbe.getTarget(); | 166 | FlowRule flowRule = fbe.getTarget(); |
| 168 | OpenFlowSwitch sw = controller.getSwitch(Dpid.dpid(flowRule.deviceId().uri())); | 167 | OpenFlowSwitch sw = controller.getSwitch(Dpid.dpid(flowRule.deviceId().uri())); |
| 168 | + if (sw == null) { | ||
| 169 | + log.warn("WTF {}", flowRule.deviceId()); | ||
| 170 | + } | ||
| 169 | sws.add(new Dpid(sw.getId())); | 171 | sws.add(new Dpid(sw.getId())); |
| 170 | FlowModBuilder builder = new FlowModBuilder(flowRule, sw.factory()); | 172 | FlowModBuilder builder = new FlowModBuilder(flowRule, sw.factory()); |
| 171 | switch (fbe.getOperator()) { | 173 | switch (fbe.getOperator()) { |
| ... | @@ -322,6 +324,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -322,6 +324,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
| 322 | 324 | ||
| 323 | public void fail(OFErrorMsg msg, Dpid dpid) { | 325 | public void fail(OFErrorMsg msg, Dpid dpid) { |
| 324 | ok.set(false); | 326 | ok.set(false); |
| 327 | + removeRequirement(dpid); | ||
| 325 | FlowEntry fe = null; | 328 | FlowEntry fe = null; |
| 326 | FlowRuleBatchEntry fbe = fms.get(msg.getXid()); | 329 | FlowRuleBatchEntry fbe = fms.get(msg.getXid()); |
| 327 | FlowRule offending = fbe.getTarget(); | 330 | FlowRule offending = fbe.getTarget(); |
| ... | @@ -375,10 +378,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -375,10 +378,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
| 375 | 378 | ||
| 376 | public void satisfyRequirement(Dpid dpid) { | 379 | public void satisfyRequirement(Dpid dpid) { |
| 377 | log.warn("Satisfaction from switch {}", dpid); | 380 | log.warn("Satisfaction from switch {}", dpid); |
| 378 | - sws.remove(dpid); | 381 | + removeRequirement(dpid); |
| 379 | - countDownLatch.countDown(); | ||
| 380 | - cleanUp(); | ||
| 381 | - | ||
| 382 | } | 382 | } |
| 383 | 383 | ||
| 384 | 384 | ||
| ... | @@ -395,6 +395,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -395,6 +395,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
| 395 | 395 | ||
| 396 | @Override | 396 | @Override |
| 397 | public boolean cancel(boolean mayInterruptIfRunning) { | 397 | public boolean cancel(boolean mayInterruptIfRunning) { |
| 398 | + ok.set(false); | ||
| 398 | this.state = BatchState.CANCELLED; | 399 | this.state = BatchState.CANCELLED; |
| 399 | cleanUp(); | 400 | cleanUp(); |
| 400 | for (FlowRuleBatchEntry fbe : fms.values()) { | 401 | for (FlowRuleBatchEntry fbe : fms.values()) { |
| ... | @@ -431,6 +432,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -431,6 +432,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
| 431 | throws InterruptedException, ExecutionException, | 432 | throws InterruptedException, ExecutionException, |
| 432 | TimeoutException { | 433 | TimeoutException { |
| 433 | if (countDownLatch.await(timeout, unit)) { | 434 | if (countDownLatch.await(timeout, unit)) { |
| 435 | + | ||
| 434 | this.state = BatchState.FINISHED; | 436 | this.state = BatchState.FINISHED; |
| 435 | return new CompletedBatchOperation(ok.get(), offendingFlowMods); | 437 | return new CompletedBatchOperation(ok.get(), offendingFlowMods); |
| 436 | } | 438 | } |
| ... | @@ -438,7 +440,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -438,7 +440,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
| 438 | } | 440 | } |
| 439 | 441 | ||
| 440 | private void cleanUp() { | 442 | private void cleanUp() { |
| 441 | - if (sws.isEmpty()) { | 443 | + if (isDone() || isCancelled()) { |
| 442 | pendingFutures.remove(pendingXid); | 444 | pendingFutures.remove(pendingXid); |
| 443 | for (Long xid : fms.keySet()) { | 445 | for (Long xid : fms.keySet()) { |
| 444 | pendingFMs.remove(xid); | 446 | pendingFMs.remove(xid); |
| ... | @@ -446,6 +448,12 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -446,6 +448,12 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
| 446 | } | 448 | } |
| 447 | } | 449 | } |
| 448 | 450 | ||
| 451 | + private void removeRequirement(Dpid dpid) { | ||
| 452 | + countDownLatch.countDown(); | ||
| 453 | + sws.remove(dpid); | ||
| 454 | + cleanUp(); | ||
| 455 | + } | ||
| 456 | + | ||
| 449 | } | 457 | } |
| 450 | 458 | ||
| 451 | } | 459 | } | ... | ... |
| ... | @@ -28,7 +28,6 @@ import org.onlab.onos.openflow.controller.OpenFlowController; | ... | @@ -28,7 +28,6 @@ import org.onlab.onos.openflow.controller.OpenFlowController; |
| 28 | import org.onlab.onos.openflow.controller.OpenFlowPacketContext; | 28 | import org.onlab.onos.openflow.controller.OpenFlowPacketContext; |
| 29 | import org.onlab.onos.openflow.controller.OpenFlowSwitch; | 29 | import org.onlab.onos.openflow.controller.OpenFlowSwitch; |
| 30 | import org.onlab.onos.openflow.controller.PacketListener; | 30 | import org.onlab.onos.openflow.controller.PacketListener; |
| 31 | -import org.onlab.packet.Ethernet; | ||
| 32 | import org.projectfloodlight.openflow.protocol.OFPacketOut; | 31 | import org.projectfloodlight.openflow.protocol.OFPacketOut; |
| 33 | import org.projectfloodlight.openflow.protocol.OFPortDesc; | 32 | import org.projectfloodlight.openflow.protocol.OFPortDesc; |
| 34 | import org.projectfloodlight.openflow.protocol.action.OFAction; | 33 | import org.projectfloodlight.openflow.protocol.action.OFAction; |
| ... | @@ -96,13 +95,13 @@ public class OpenFlowPacketProvider extends AbstractProvider implements PacketPr | ... | @@ -96,13 +95,13 @@ public class OpenFlowPacketProvider extends AbstractProvider implements PacketPr |
| 96 | return; | 95 | return; |
| 97 | } | 96 | } |
| 98 | 97 | ||
| 99 | - Ethernet eth = new Ethernet(); | 98 | + //Ethernet eth = new Ethernet(); |
| 100 | - eth.deserialize(packet.data().array(), 0, packet.data().array().length); | 99 | + //eth.deserialize(packet.data().array(), 0, packet.data().array().length); |
| 101 | OFPortDesc p = null; | 100 | OFPortDesc p = null; |
| 102 | for (Instruction inst : packet.treatment().instructions()) { | 101 | for (Instruction inst : packet.treatment().instructions()) { |
| 103 | if (inst.type().equals(Instruction.Type.OUTPUT)) { | 102 | if (inst.type().equals(Instruction.Type.OUTPUT)) { |
| 104 | p = portDesc(((OutputInstruction) inst).port()); | 103 | p = portDesc(((OutputInstruction) inst).port()); |
| 105 | - OFPacketOut po = packetOut(sw, eth, p.getPortNo()); | 104 | + OFPacketOut po = packetOut(sw, packet.data().array(), p.getPortNo()); |
| 106 | sw.sendMsg(po); | 105 | sw.sendMsg(po); |
| 107 | } | 106 | } |
| 108 | } | 107 | } |
| ... | @@ -116,7 +115,7 @@ public class OpenFlowPacketProvider extends AbstractProvider implements PacketPr | ... | @@ -116,7 +115,7 @@ public class OpenFlowPacketProvider extends AbstractProvider implements PacketPr |
| 116 | return builder.build(); | 115 | return builder.build(); |
| 117 | } | 116 | } |
| 118 | 117 | ||
| 119 | - private OFPacketOut packetOut(OpenFlowSwitch sw, Ethernet eth, OFPort out) { | 118 | + private OFPacketOut packetOut(OpenFlowSwitch sw, byte[] eth, OFPort out) { |
| 120 | OFPacketOut.Builder builder = sw.factory().buildPacketOut(); | 119 | OFPacketOut.Builder builder = sw.factory().buildPacketOut(); |
| 121 | OFAction act = sw.factory().actions() | 120 | OFAction act = sw.factory().actions() |
| 122 | .buildOutput() | 121 | .buildOutput() |
| ... | @@ -126,7 +125,7 @@ public class OpenFlowPacketProvider extends AbstractProvider implements PacketPr | ... | @@ -126,7 +125,7 @@ public class OpenFlowPacketProvider extends AbstractProvider implements PacketPr |
| 126 | .setBufferId(OFBufferId.NO_BUFFER) | 125 | .setBufferId(OFBufferId.NO_BUFFER) |
| 127 | .setInPort(OFPort.NO_MASK) | 126 | .setInPort(OFPort.NO_MASK) |
| 128 | .setActions(Collections.singletonList(act)) | 127 | .setActions(Collections.singletonList(act)) |
| 129 | - .setData(eth.serialize()) | 128 | + .setData(eth) |
| 130 | .build(); | 129 | .build(); |
| 131 | } | 130 | } |
| 132 | 131 | ... | ... |
| ... | @@ -2,5 +2,5 @@ | ... | @@ -2,5 +2,5 @@ |
| 2 | 2 | ||
| 3 | export ONOS_FEATURES="webconsole,onos-api,onos-core-trivial,onos-cli,onos-openflow,onos-app-fwd,onos-app-mobility,onos-app-tvue,onos-app-proxyarp" | 3 | export ONOS_FEATURES="webconsole,onos-api,onos-core-trivial,onos-cli,onos-openflow,onos-app-fwd,onos-app-mobility,onos-app-tvue,onos-app-proxyarp" |
| 4 | 4 | ||
| 5 | -export ONOS_NIC="10.128.4.*" | 5 | +export ONOS_NIC="10.1.10.*" |
| 6 | -export OC1="10.128.4.60" | 6 | +export OC1="10.1.10.223" | ... | ... |
| 1 | +package org.onlab.packet; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * The class representing a network device chassisId. | ||
| 5 | + * This class is immutable. | ||
| 6 | + */ | ||
| 7 | +// TODO: Move this to a reasonable place. | ||
| 8 | +public final class ChassisId { | ||
| 9 | + | ||
| 10 | + private static final long UNKNOWN = 0; | ||
| 11 | + private final long value; | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * Default constructor. | ||
| 15 | + */ | ||
| 16 | + public ChassisId() { | ||
| 17 | + this.value = ChassisId.UNKNOWN; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * Constructor from a long value. | ||
| 22 | + * | ||
| 23 | + * @param value the value to use. | ||
| 24 | + */ | ||
| 25 | + public ChassisId(long value) { | ||
| 26 | + this.value = value; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Constructor from a string. | ||
| 31 | + * | ||
| 32 | + * @param value the value to use. | ||
| 33 | + */ | ||
| 34 | + public ChassisId(String value) { | ||
| 35 | + this.value = Long.valueOf(value); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * Get the value of the chassis id. | ||
| 40 | + * | ||
| 41 | + * @return the value of the chassis id. | ||
| 42 | + */ | ||
| 43 | + public long value() { | ||
| 44 | + return value; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * Convert the Chassis Id value to a ':' separated hexadecimal string. | ||
| 49 | + * | ||
| 50 | + * @return the Chassis Id value as a ':' separated hexadecimal string. | ||
| 51 | + */ | ||
| 52 | + @Override | ||
| 53 | + public String toString() { | ||
| 54 | + return Long.toHexString(this.value); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + @Override | ||
| 58 | + public boolean equals(Object other) { | ||
| 59 | + if (!(other instanceof ChassisId)) { | ||
| 60 | + return false; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + ChassisId otherChassisId = (ChassisId) other; | ||
| 64 | + | ||
| 65 | + return value == otherChassisId.value; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + @Override | ||
| 69 | + public int hashCode() { | ||
| 70 | + int hash = 17; | ||
| 71 | + hash += 31 * hash + (int) (value ^ value >>> 32); | ||
| 72 | + return hash; | ||
| 73 | + } | ||
| 74 | +} |
| ... | @@ -58,6 +58,7 @@ public class Ethernet extends BasePacket { | ... | @@ -58,6 +58,7 @@ public class Ethernet extends BasePacket { |
| 58 | Ethernet.etherTypeClassMap.put(Ethernet.TYPE_RARP, ARP.class); | 58 | Ethernet.etherTypeClassMap.put(Ethernet.TYPE_RARP, ARP.class); |
| 59 | Ethernet.etherTypeClassMap.put(Ethernet.TYPE_IPV4, IPv4.class); | 59 | Ethernet.etherTypeClassMap.put(Ethernet.TYPE_IPV4, IPv4.class); |
| 60 | Ethernet.etherTypeClassMap.put(Ethernet.TYPE_LLDP, LLDP.class); | 60 | Ethernet.etherTypeClassMap.put(Ethernet.TYPE_LLDP, LLDP.class); |
| 61 | + Ethernet.etherTypeClassMap.put(Ethernet.TYPE_BSN, LLDP.class); | ||
| 61 | } | 62 | } |
| 62 | 63 | ||
| 63 | protected MacAddress destinationMACAddress; | 64 | protected MacAddress destinationMACAddress; | ... | ... |
| ... | @@ -150,7 +150,7 @@ public class LLDP extends BasePacket { | ... | @@ -150,7 +150,7 @@ public class LLDP extends BasePacket { |
| 150 | final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); | 150 | final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); |
| 151 | LLDPTLV tlv; | 151 | LLDPTLV tlv; |
| 152 | do { | 152 | do { |
| 153 | - tlv = new LLDPTLV().deserialize(bb); | 153 | + tlv = new LLDPOrganizationalTLV().deserialize(bb); |
| 154 | 154 | ||
| 155 | // if there was a failure to deserialize stop processing TLVs | 155 | // if there was a failure to deserialize stop processing TLVs |
| 156 | if (tlv == null) { | 156 | if (tlv == null) { |
| ... | @@ -169,6 +169,7 @@ public class LLDP extends BasePacket { | ... | @@ -169,6 +169,7 @@ public class LLDP extends BasePacket { |
| 169 | case 0x3: | 169 | case 0x3: |
| 170 | this.ttl = tlv; | 170 | this.ttl = tlv; |
| 171 | break; | 171 | break; |
| 172 | + | ||
| 172 | default: | 173 | default: |
| 173 | this.optionalTLVList.add(tlv); | 174 | this.optionalTLVList.add(tlv); |
| 174 | break; | 175 | break; | ... | ... |
| ... | @@ -140,6 +140,9 @@ public class LLDPOrganizationalTLV extends LLDPTLV { | ... | @@ -140,6 +140,9 @@ public class LLDPOrganizationalTLV extends LLDPTLV { |
| 140 | 140 | ||
| 141 | @Override | 141 | @Override |
| 142 | public byte[] serialize() { | 142 | public byte[] serialize() { |
| 143 | + if (this.type != LLDPOrganizationalTLV.ORGANIZATIONAL_TLV_TYPE) { | ||
| 144 | + return super.serialize(); | ||
| 145 | + } | ||
| 143 | final int valueLength = LLDPOrganizationalTLV.OUI_LENGTH | 146 | final int valueLength = LLDPOrganizationalTLV.OUI_LENGTH |
| 144 | + LLDPOrganizationalTLV.SUBTYPE_LENGTH + this.infoString.length; | 147 | + LLDPOrganizationalTLV.SUBTYPE_LENGTH + this.infoString.length; |
| 145 | this.value = new byte[valueLength]; | 148 | this.value = new byte[valueLength]; |
| ... | @@ -152,7 +155,11 @@ public class LLDPOrganizationalTLV extends LLDPTLV { | ... | @@ -152,7 +155,11 @@ public class LLDPOrganizationalTLV extends LLDPTLV { |
| 152 | 155 | ||
| 153 | @Override | 156 | @Override |
| 154 | public LLDPTLV deserialize(final ByteBuffer bb) { | 157 | public LLDPTLV deserialize(final ByteBuffer bb) { |
| 155 | - super.deserialize(bb); | 158 | + LLDPTLV tlv = super.deserialize(bb); |
| 159 | + if (tlv.getType() != LLDPOrganizationalTLV.ORGANIZATIONAL_TLV_TYPE) { | ||
| 160 | + return tlv; | ||
| 161 | + } | ||
| 162 | + | ||
| 156 | final ByteBuffer optionalField = ByteBuffer.wrap(this.value); | 163 | final ByteBuffer optionalField = ByteBuffer.wrap(this.value); |
| 157 | 164 | ||
| 158 | final byte[] oui = new byte[LLDPOrganizationalTLV.OUI_LENGTH]; | 165 | final byte[] oui = new byte[LLDPOrganizationalTLV.OUI_LENGTH]; | ... | ... |
| ... | @@ -111,6 +111,7 @@ public class LLDPTLV { | ... | @@ -111,6 +111,7 @@ public class LLDPTLV { |
| 111 | sscratch = bb.getShort(); | 111 | sscratch = bb.getShort(); |
| 112 | this.type = (byte) (sscratch >> 9 & 0x7f); | 112 | this.type = (byte) (sscratch >> 9 & 0x7f); |
| 113 | this.length = (short) (sscratch & 0x1ff); | 113 | this.length = (short) (sscratch & 0x1ff); |
| 114 | + | ||
| 114 | if (this.length > 0) { | 115 | if (this.length > 0) { |
| 115 | this.value = new byte[this.length]; | 116 | this.value = new byte[this.length]; |
| 116 | 117 | ||
| ... | @@ -120,6 +121,7 @@ public class LLDPTLV { | ... | @@ -120,6 +121,7 @@ public class LLDPTLV { |
| 120 | } | 121 | } |
| 121 | bb.get(this.value); | 122 | bb.get(this.value); |
| 122 | } | 123 | } |
| 124 | + | ||
| 123 | return this; | 125 | return this; |
| 124 | } | 126 | } |
| 125 | 127 | ... | ... |
| ... | @@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory; | ... | @@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory; |
| 30 | * Refer to IEEE Std 802.1ABTM-2009 for more information. | 30 | * Refer to IEEE Std 802.1ABTM-2009 for more information. |
| 31 | * | 31 | * |
| 32 | */ | 32 | */ |
| 33 | +@Deprecated | ||
| 33 | public class ONLabLddp extends LLDP { | 34 | public class ONLabLddp extends LLDP { |
| 34 | 35 | ||
| 35 | private static final Logger LOG = LoggerFactory.getLogger(ONLabLddp.class); | 36 | private static final Logger LOG = LoggerFactory.getLogger(ONLabLddp.class); | ... | ... |
| 1 | +package org.onlab.packet; | ||
| 2 | + | ||
| 3 | +import com.google.common.collect.Lists; | ||
| 4 | +import org.apache.commons.lang.ArrayUtils; | ||
| 5 | + | ||
| 6 | +import java.nio.ByteBuffer; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * ONOS LLDP containing organizational TLV for ONOS device dicovery. | ||
| 10 | + */ | ||
| 11 | +public class ONOSLLDP extends LLDP { | ||
| 12 | + | ||
| 13 | + public static final byte[] ONLAB_OUI = {(byte) 0xa4, 0x23, 0x05}; | ||
| 14 | + public static final String DEFAULT_DEVICE = "INVALID"; | ||
| 15 | + public static final String DEFAULT_NAME = "ONOS Discovery"; | ||
| 16 | + | ||
| 17 | + public static final byte[] LLDP_NICIRA = {0x01, 0x23, 0x20, 0x00, 0x00, | ||
| 18 | + 0x01}; | ||
| 19 | + public static final byte[] LLDP_MULTICAST = {0x01, (byte) 0x80, | ||
| 20 | + (byte) 0xc2, 0x00, 0x00, 0x0e}; | ||
| 21 | + public static final byte[] BDDP_MULTICAST = {(byte) 0xff, (byte) 0xff, | ||
| 22 | + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff}; | ||
| 23 | + | ||
| 24 | + private static final byte NAME_SUBTYPE = 1; | ||
| 25 | + private static final byte DEVICE_SUBTYPE = 2; | ||
| 26 | + private static final short NAME_LENGTH = 4; //1 for subtype + 3 for OUI | ||
| 27 | + private static final short DEVICE_LENGTH = 4; //1 for subtype + 3 for OUI | ||
| 28 | + private final LLDPOrganizationalTLV nameTLV = new LLDPOrganizationalTLV(); | ||
| 29 | + private final LLDPOrganizationalTLV deviceTLV = new LLDPOrganizationalTLV(); | ||
| 30 | + | ||
| 31 | + // TLV constants: type, size and subtype | ||
| 32 | + // Organizationally specific TLV also have packet offset and contents of TLV | ||
| 33 | + // header | ||
| 34 | + private static final byte CHASSIS_TLV_TYPE = 1; | ||
| 35 | + private static final byte CHASSIS_TLV_SIZE = 7; | ||
| 36 | + private static final byte CHASSIS_TLV_SUBTYPE = 4; | ||
| 37 | + | ||
| 38 | + private static final byte PORT_TLV_TYPE = 2; | ||
| 39 | + private static final byte PORT_TLV_SIZE = 5; | ||
| 40 | + private static final byte PORT_TLV_SUBTYPE = 2; | ||
| 41 | + | ||
| 42 | + private static final byte TTL_TLV_TYPE = 3; | ||
| 43 | + | ||
| 44 | + | ||
| 45 | + private final byte[] ttlValue = new byte[] {0, 0x78}; | ||
| 46 | + | ||
| 47 | + public ONOSLLDP() { | ||
| 48 | + super(); | ||
| 49 | + setName(DEFAULT_NAME); | ||
| 50 | + setDevice(DEFAULT_DEVICE); | ||
| 51 | + setOptionalTLVList(Lists.<LLDPTLV>newArrayList(nameTLV, deviceTLV)); | ||
| 52 | + setTtl(new LLDPTLV().setType((byte) TTL_TLV_TYPE) | ||
| 53 | + .setLength((short) ttlValue.length) | ||
| 54 | + .setValue(ttlValue)); | ||
| 55 | + | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + private ONOSLLDP(LLDP lldp) { | ||
| 59 | + this.portId = lldp.getPortId(); | ||
| 60 | + this.chassisId = lldp.getChassisId(); | ||
| 61 | + this.ttl = lldp.getTtl(); | ||
| 62 | + this.optionalTLVList = lldp.getOptionalTLVList(); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public void setName(String name) { | ||
| 66 | + nameTLV.setLength((short) (name.length() + NAME_LENGTH)); | ||
| 67 | + nameTLV.setInfoString(name); | ||
| 68 | + nameTLV.setSubType(NAME_SUBTYPE); | ||
| 69 | + nameTLV.setOUI(ONLAB_OUI); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + public void setDevice(String device) { | ||
| 73 | + deviceTLV.setInfoString(device); | ||
| 74 | + deviceTLV.setLength((short) (device.length() + DEVICE_LENGTH)); | ||
| 75 | + deviceTLV.setSubType(DEVICE_SUBTYPE); | ||
| 76 | + deviceTLV.setOUI(ONLAB_OUI); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + public void setChassisId(final ChassisId chassisId) { | ||
| 80 | + MacAddress chassisMac = MacAddress.valueOf(chassisId.value()); | ||
| 81 | + byte[] chassis = ArrayUtils.addAll(new byte[] {CHASSIS_TLV_SUBTYPE}, | ||
| 82 | + chassisMac.getAddress()); | ||
| 83 | + | ||
| 84 | + LLDPTLV chassisTLV = new LLDPTLV(); | ||
| 85 | + chassisTLV.setLength(CHASSIS_TLV_SIZE); | ||
| 86 | + chassisTLV.setType(CHASSIS_TLV_TYPE); | ||
| 87 | + chassisTLV.setValue(chassis); | ||
| 88 | + this.setChassisId(chassisTLV); | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + public void setPortId(final int portNumber) { | ||
| 92 | + byte[] port = ArrayUtils.addAll(new byte[] {PORT_TLV_SUBTYPE}, | ||
| 93 | + ByteBuffer.allocate(4).putInt(portNumber).array()); | ||
| 94 | + | ||
| 95 | + LLDPTLV portTLV = new LLDPTLV(); | ||
| 96 | + portTLV.setLength(PORT_TLV_SIZE); | ||
| 97 | + portTLV.setType(PORT_TLV_TYPE); | ||
| 98 | + portTLV.setValue(port); | ||
| 99 | + this.setPortId(portTLV); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + public LLDPOrganizationalTLV getNameTLV() { | ||
| 103 | + for (LLDPTLV tlv : this.getOptionalTLVList()) { | ||
| 104 | + if (tlv.getType() == LLDPOrganizationalTLV.ORGANIZATIONAL_TLV_TYPE) { | ||
| 105 | + LLDPOrganizationalTLV orgTLV = (LLDPOrganizationalTLV) tlv; | ||
| 106 | + if (orgTLV.getSubType() == NAME_SUBTYPE) { | ||
| 107 | + return orgTLV; | ||
| 108 | + } | ||
| 109 | + } | ||
| 110 | + } | ||
| 111 | + return null; | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + public LLDPOrganizationalTLV getDeviceTLV() { | ||
| 115 | + for (LLDPTLV tlv : this.getOptionalTLVList()) { | ||
| 116 | + if (tlv.getType() == LLDPOrganizationalTLV.ORGANIZATIONAL_TLV_TYPE) { | ||
| 117 | + LLDPOrganizationalTLV orgTLV = (LLDPOrganizationalTLV) tlv; | ||
| 118 | + if (orgTLV.getSubType() == DEVICE_SUBTYPE) { | ||
| 119 | + return orgTLV; | ||
| 120 | + } | ||
| 121 | + } | ||
| 122 | + } | ||
| 123 | + return null; | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + public String getNameString() { | ||
| 127 | + LLDPOrganizationalTLV tlv = getNameTLV(); | ||
| 128 | + if (tlv != null) { | ||
| 129 | + return new String(tlv.getInfoString()); | ||
| 130 | + } | ||
| 131 | + return null; | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + public String getDeviceString() { | ||
| 135 | + LLDPOrganizationalTLV tlv = getDeviceTLV(); | ||
| 136 | + if (tlv != null) { | ||
| 137 | + return new String(tlv.getInfoString()); | ||
| 138 | + } | ||
| 139 | + return null; | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + public Integer getPort() { | ||
| 143 | + ByteBuffer portBB = ByteBuffer.wrap(this.getPortId().getValue()); | ||
| 144 | + portBB.position(1); | ||
| 145 | + return portBB.getInt(); | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + /** | ||
| 149 | + * Given an ethernet packet, determines if this is an LLDP from | ||
| 150 | + * ONOS and returns the device the LLDP came from. | ||
| 151 | + * @param eth an ethernet packet | ||
| 152 | + * @return a the lldp packet or null | ||
| 153 | + */ | ||
| 154 | + public static ONOSLLDP parseONOSLLDP(Ethernet eth) { | ||
| 155 | + if (eth.getEtherType() == Ethernet.TYPE_LLDP || | ||
| 156 | + eth.getEtherType() == Ethernet.TYPE_BSN) { | ||
| 157 | + ONOSLLDP onosLldp = new ONOSLLDP((LLDP) eth.getPayload()); //(ONOSLLDP) eth.getPayload(); | ||
| 158 | + if (ONOSLLDP.DEFAULT_NAME.equals(onosLldp.getNameString())) { | ||
| 159 | + return onosLldp; | ||
| 160 | + } | ||
| 161 | + } | ||
| 162 | + return null; | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + | ||
| 166 | + | ||
| 167 | + | ||
| 168 | + | ||
| 169 | +} |
-
Please register or login to post a comment