Search in sources :

Example 21 with DefaultAnnotations

use of org.onosproject.net.DefaultAnnotations in project onos by opennetworkinglab.

the class JuniperUtils method createBiDirLinkDescription.

/**
 * Create two LinkDescriptions corresponding to the bidirectional links.
 *
 * @param localDevId  the identity of the local device
 * @param localPort   the port of the local device
 * @param remoteDevId the identity of the remote device
 * @param remotePort  the port of the remote device
 * @param descs       the collection to which the link descriptions
 *                    should be added
 */
public static void createBiDirLinkDescription(DeviceId localDevId, Port localPort, DeviceId remoteDevId, Port remotePort, Set<LinkDescription> descs) {
    ConnectPoint local = new ConnectPoint(localDevId, localPort.number());
    ConnectPoint remote = new ConnectPoint(remoteDevId, remotePort.number());
    DefaultAnnotations annotations = DefaultAnnotations.builder().set(AnnotationKeys.LAYER, "ETHERNET").build();
    descs.add(new DefaultLinkDescription(local, remote, Link.Type.DIRECT, true, annotations));
    descs.add(new DefaultLinkDescription(remote, local, Link.Type.DIRECT, true, annotations));
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription)

Example 22 with DefaultAnnotations

use of org.onosproject.net.DefaultAnnotations in project onos by opennetworkinglab.

the class ECDeviceStore method mergeAnnotations.

private DefaultAnnotations mergeAnnotations(DeviceId deviceId) {
    ProviderId primaryProviderId = getPrimaryProviderId(deviceId);
    DeviceDescription primaryDeviceDescription = deviceDescriptions.get(new DeviceKey(primaryProviderId, deviceId));
    DefaultAnnotations annotations = DefaultAnnotations.builder().build();
    annotations = merge(annotations, primaryDeviceDescription.annotations());
    for (ProviderId providerId : getAllProviders(deviceId)) {
        if (!providerId.equals(primaryProviderId)) {
            annotations = merge(annotations, deviceDescriptions.get(new DeviceKey(providerId, deviceId)).annotations());
        }
    }
    return annotations;
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) DeviceDescription(org.onosproject.net.device.DeviceDescription) DefaultAnnotations(org.onosproject.net.DefaultAnnotations)

Example 23 with DefaultAnnotations

use of org.onosproject.net.DefaultAnnotations 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 24 with DefaultAnnotations

use of org.onosproject.net.DefaultAnnotations in project onos by opennetworkinglab.

the class AnnotationConstraintTest method setUp.

@Before
public void setUp() {
    resourceContext = createMock(ResourceContext.class);
    DefaultAnnotations annotations = DefaultAnnotations.builder().set(KEY, String.valueOf(VALUE)).build();
    link = DefaultLink.builder().providerId(PID).src(cp(DID1, PID1)).dst(cp(DID2, PID2)).type(DIRECT).annotations(annotations).build();
}
Also used : ResourceContext(org.onosproject.net.intent.ResourceContext) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Before(org.junit.Before)

Example 25 with DefaultAnnotations

use of org.onosproject.net.DefaultAnnotations in project onos by opennetworkinglab.

the class FujitsuT100DeviceDescription method parseT100OduPort.

private static PortDescription parseT100OduPort(HierarchicalConfiguration cfg, long count) {
    PortNumber portNumber = PortNumber.portNumber(count);
    HierarchicalConfiguration ethernetConfig = cfg.configurationAt("ethernet");
    boolean enabled = "up".equals(ethernetConfig.getString("administrative-state"));
    // Rate is in kbps
    CltSignalType signalType = "100000000".equals(ethernetConfig.getString("rate")) ? CltSignalType.CLT_100GBE : null;
    DefaultAnnotations annotations = DefaultAnnotations.builder().set(AnnotationKeys.PORT_NAME, cfg.getString("name")).build();
    return oduCltPortDescription(portNumber, enabled, signalType, annotations);
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) CltSignalType(org.onosproject.net.CltSignalType) PortNumber(org.onosproject.net.PortNumber) HierarchicalConfiguration(org.apache.commons.configuration.HierarchicalConfiguration)

Aggregations

DefaultAnnotations (org.onosproject.net.DefaultAnnotations)33 ConnectPoint (org.onosproject.net.ConnectPoint)9 PortDescription (org.onosproject.net.device.PortDescription)9 DefaultLinkDescription (org.onosproject.net.link.DefaultLinkDescription)8 DeviceId (org.onosproject.net.DeviceId)7 PortNumber (org.onosproject.net.PortNumber)7 ProviderId (org.onosproject.net.provider.ProviderId)7 DefaultPortDescription (org.onosproject.net.device.DefaultPortDescription)6 LinkDescription (org.onosproject.net.link.LinkDescription)6 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)4 Device (org.onosproject.net.Device)4 DeviceDescription (org.onosproject.net.device.DeviceDescription)4 ArrayList (java.util.ArrayList)3 ChassisId (org.onlab.packet.ChassisId)3 DefaultDevice (org.onosproject.net.DefaultDevice)3 DefaultDeviceDescription (org.onosproject.net.device.DefaultDeviceDescription)3 DeviceService (org.onosproject.net.device.DeviceService)3 XPath (javax.xml.xpath.XPath)2 XPathExpressionException (javax.xml.xpath.XPathExpressionException)2 Test (org.junit.Test)2