Search in sources :

Example 6 with DefaultDevice

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());
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) DeviceDescription(org.onosproject.net.device.DeviceDescription) Type(org.onosproject.net.Device.Type) ChassisId(org.onlab.packet.ChassisId) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) DefaultDevice(org.onosproject.net.DefaultDevice)

Example 7 with DefaultDevice

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);
}
Also used : Response(javax.ws.rs.core.Response) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) DeviceId(org.onosproject.net.DeviceId) DefaultDevice(org.onosproject.net.DefaultDevice) Device(org.onosproject.net.Device) DefaultVirtualDevice(org.onosproject.incubator.net.virtual.DefaultVirtualDevice) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) InputStream(java.io.InputStream) DefaultDevice(org.onosproject.net.DefaultDevice) WebTarget(javax.ws.rs.client.WebTarget) Matchers.containsString(org.hamcrest.Matchers.containsString) NetworkId(org.onosproject.incubator.net.virtual.NetworkId) ConnectPoint(org.onosproject.net.ConnectPoint) LinksResourceTest(org.onosproject.rest.resources.LinksResourceTest) ResourceTest(org.onosproject.rest.resources.ResourceTest) HostResourceTest(org.onosproject.rest.resources.HostResourceTest) Test(org.junit.Test)

Example 8 with DefaultDevice

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));
}
Also used : Device(org.onosproject.net.Device) DefaultDevice(org.onosproject.net.DefaultDevice) DefaultDevice(org.onosproject.net.DefaultDevice) Test(org.junit.Test)

Example 9 with DefaultDevice

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));
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Annotations(org.onosproject.net.Annotations) Device(org.onosproject.net.Device) DefaultDevice(org.onosproject.net.DefaultDevice) DefaultDevice(org.onosproject.net.DefaultDevice) Test(org.junit.Test)

Example 10 with DefaultDevice

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));
}
Also used : Device(org.onosproject.net.Device) DefaultDevice(org.onosproject.net.DefaultDevice) DefaultPort(org.onosproject.net.DefaultPort) Port(org.onosproject.net.Port) DefaultDevice(org.onosproject.net.DefaultDevice) DefaultPort(org.onosproject.net.DefaultPort) Test(org.junit.Test)

Aggregations

DefaultDevice (org.onosproject.net.DefaultDevice)22 Device (org.onosproject.net.Device)14 Test (org.junit.Test)13 ChassisId (org.onlab.packet.ChassisId)13 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)10 Annotations (org.onosproject.net.Annotations)5 DefaultPort (org.onosproject.net.DefaultPort)5 DeviceId (org.onosproject.net.DeviceId)5 ProviderId (org.onosproject.net.provider.ProviderId)5 HashMap (java.util.HashMap)4 Type (org.onosproject.net.Device.Type)4 Before (org.junit.Before)3 Port (org.onosproject.net.Port)3 Behaviour (org.onosproject.net.driver.Behaviour)3 DefaultDriver (org.onosproject.net.driver.DefaultDriver)3 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 TestEventDispatcher (org.onosproject.common.event.impl.TestEventDispatcher)2 MepId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)2 CfmConfigException (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)2