use of org.onosproject.net.DefaultDevice in project onos by opennetworkinglab.
the class GossipDeviceStore method composeDevice.
/**
* Returns a Device, merging description given from multiple Providers.
*
* @param deviceId device identifier
* @param providerDescs Collection of Descriptions from multiple providers
* @return Device instance
*/
private Device composeDevice(DeviceId deviceId, Map<ProviderId, DeviceDescriptions> providerDescs) {
checkArgument(!providerDescs.isEmpty(), "No device descriptions supplied");
ProviderId primary = pickPrimaryPid(providerDescs);
DeviceDescriptions desc = providerDescs.get(primary);
final DeviceDescription base = desc.getDeviceDesc().value();
Type type = base.type();
String manufacturer = base.manufacturer();
String hwVersion = base.hwVersion();
String swVersion = base.swVersion();
String serialNumber = base.serialNumber();
ChassisId chassisId = base.chassisId();
DefaultAnnotations.Builder annotations = DefaultAnnotations.builder();
annotations.putAll(base.annotations());
for (Entry<ProviderId, DeviceDescriptions> e : providerDescs.entrySet()) {
if (e.getKey().equals(primary)) {
continue;
}
// Note: should keep track of Description timestamp in the future
// and only merge conflicting keys when timestamp is newer.
// Currently assuming there will never be a key conflict between
// providers
// annotation merging. not so efficient, should revisit later
annotations.putAll(e.getValue().getDeviceDesc().value().annotations());
}
return new DefaultDevice(primary, deviceId, type, manufacturer, hwVersion, swVersion, serialNumber, chassisId, annotations.buildCompressed());
}
use of org.onosproject.net.DefaultDevice in project onos by opennetworkinglab.
the class VirtualNetworkWebResourceTest method testPostVirtualPort.
/**
* Tests adding of new virtual port using POST via JSON stream.
*/
@Test
public void testPostVirtualPort() {
NetworkId networkId = networkId3;
DeviceId deviceId = devId22;
DefaultAnnotations annotations = DefaultAnnotations.builder().build();
Device physDevice = new DefaultDevice(null, DeviceId.deviceId("dev1"), null, null, null, null, null, null, annotations);
ConnectPoint cp1 = new ConnectPoint(physDevice.id(), portNumber(1));
expect(mockVnetAdminService.createVirtualPort(networkId, deviceId, portNumber(22), cp1)).andReturn(vport22);
replay(mockVnetAdminService);
WebTarget wt = target();
InputStream jsonStream = VirtualNetworkWebResourceTest.class.getResourceAsStream("post-virtual-port.json");
String reqLocation = "vnets/" + networkId.toString() + "/devices/" + deviceId.toString() + "/ports";
Response response = wt.path(reqLocation).request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(jsonStream));
assertThat(response.getStatus(), is(HttpURLConnection.HTTP_CREATED));
verify(mockVnetAdminService);
}
use of org.onosproject.net.DefaultDevice in project onos by opennetworkinglab.
the class SuppressionRulesTest method testNotSuppressedDevice.
@Test
public void testNotSuppressedDevice() {
Device device = new DefaultDevice(PID, NON_SUPPRESSED_DID, Device.Type.SWITCH, MFR, HW, SW1, SN, CID);
assertFalse(rules.isSuppressed(device));
}
use of org.onosproject.net.DefaultDevice in project onos by opennetworkinglab.
the class SuppressionRulesTest method testSuppressedDeviceAnnotationExact.
@Test
public void testSuppressedDeviceAnnotationExact() {
Annotations annotation = DefaultAnnotations.builder().set("sendLLDP", "false").build();
Device device = new DefaultDevice(PID, NON_SUPPRESSED_DID, Device.Type.SWITCH, MFR, HW, SW1, SN, CID, annotation);
assertTrue(rules.isSuppressed(device));
}
use of org.onosproject.net.DefaultDevice in project onos by opennetworkinglab.
the class SuppressionRulesTest method testNotSuppressedPort.
@Test
public void testNotSuppressedPort() {
Device device = new DefaultDevice(PID, NON_SUPPRESSED_DID, Device.Type.SWITCH, MFR, HW, SW1, SN, CID);
Port port = new DefaultPort(device, P1, true);
assertFalse(rules.isSuppressed(port));
}
Aggregations