Search in sources :

Example 1 with NodeConnectorUpdated

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated in project openflowplugin by opendaylight.

the class NodeConnectorNotificationSupplierImpl method createNotification.

@Override
public NodeConnectorUpdated createNotification(final FlowCapableNodeConnector flowCapableNodeConnector, final InstanceIdentifier<FlowCapableNodeConnector> path) {
    Preconditions.checkArgument(flowCapableNodeConnector != null);
    Preconditions.checkArgument(path != null);
    final NodeConnectorUpdatedBuilder notifBuilder = new NodeConnectorUpdatedBuilder();
    final FlowCapableNodeConnectorUpdatedBuilder connNotifBuilder = new FlowCapableNodeConnectorUpdatedBuilder(flowCapableNodeConnector);
    notifBuilder.setId(path.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId());
    notifBuilder.setNodeConnectorRef(new NodeConnectorRef(path));
    notifBuilder.addAugmentation(FlowCapableNodeConnectorUpdated.class, connNotifBuilder.build());
    return notifBuilder.build();
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) FlowCapableNodeConnectorUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdatedBuilder) NodeConnectorUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdatedBuilder) FlowCapableNodeConnectorUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdatedBuilder)

Example 2 with NodeConnectorUpdated

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated in project openflowplugin by opendaylight.

the class PortTranslatorUtilTest method testTranslatePort.

/**
 * Test  method for
 * {@link PortTranslatorUtil#translatePort(Short, java.math.BigInteger,
 * Long, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping)} ()}.
 */
@Test
public void testTranslatePort() {
    Short version = OpenflowVersion.OF10.getVersion();
    BigInteger dataPathId = BigInteger.ONE;
    Long portNumber = Long.MAX_VALUE;
    PortGrouping portGrouping = mockPortGrouping();
    NodeConnectorUpdated nodeConnectorUpdated = PortTranslatorUtil.translatePort(version, dataPathId, portNumber, portGrouping);
    assertNotNull(nodeConnectorUpdated);
    version = OpenflowVersion.OF13.getVersion();
    nodeConnectorUpdated = PortTranslatorUtil.translatePort(version, dataPathId, portNumber, portGrouping);
    assertNotNull(nodeConnectorUpdated);
    version = OpenflowVersion.UNSUPPORTED.getVersion();
    nodeConnectorUpdated = PortTranslatorUtil.translatePort(version, dataPathId, portNumber, portGrouping);
    assertNotNull(nodeConnectorUpdated);
}
Also used : PortGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping) BigInteger(java.math.BigInteger) NodeConnectorUpdated(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated) Test(org.junit.Test)

Example 3 with NodeConnectorUpdated

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated in project openflowplugin by opendaylight.

the class PortTranslatorUtil method translatePort.

public static NodeConnectorUpdated translatePort(final Short version, final BigInteger datapathId, final Long portNumber, final PortGrouping port) {
    OpenflowVersion ofVersion = OpenflowVersion.get(version);
    final NodeConnectorUpdatedBuilder builder = InventoryDataServiceUtil.nodeConnectorUpdatedBuilderFromDatapathIdPortNo(datapathId, port.getPortNo(), ofVersion);
    FlowCapableNodeConnectorUpdatedBuilder fcncub = new FlowCapableNodeConnectorUpdatedBuilder();
    if (ofVersion == OpenflowVersion.OF13) {
        fcncub.setAdvertisedFeatures(PortTranslatorUtil.translatePortFeatures(port.getAdvertisedFeatures()));
        fcncub.setConfiguration(PortTranslatorUtil.translatePortConfig(port.getConfig()));
        fcncub.setCurrentFeature(PortTranslatorUtil.translatePortFeatures(port.getCurrentFeatures()));
        fcncub.setPeerFeatures(PortTranslatorUtil.translatePortFeatures(port.getPeerFeatures()));
        fcncub.setState(PortTranslatorUtil.translatePortState(port.getState()));
        fcncub.setSupported(PortTranslatorUtil.translatePortFeatures(port.getSupportedFeatures()));
    } else if (ofVersion == OpenflowVersion.OF10) {
        fcncub.setAdvertisedFeatures(PortTranslatorUtil.translatePortFeatures(port.getAdvertisedFeaturesV10()));
        fcncub.setConfiguration(PortTranslatorUtil.translatePortConfig(port.getConfigV10()));
        fcncub.setCurrentFeature(PortTranslatorUtil.translatePortFeatures(port.getCurrentFeaturesV10()));
        fcncub.setPeerFeatures(PortTranslatorUtil.translatePortFeatures(port.getPeerFeaturesV10()));
        fcncub.setState(PortTranslatorUtil.translatePortState(port.getStateV10()));
        fcncub.setSupported(PortTranslatorUtil.translatePortFeatures(port.getSupportedFeaturesV10()));
    }
    if (port instanceof PortStatusMessage) {
        if (((PortStatusMessage) port).getReason() != null) {
            fcncub.setReason(PortReason.forValue(((PortStatusMessage) port).getReason().getIntValue()));
        } else {
            LOG.debug("PortStatus Message has reason as null");
        }
    }
    fcncub.setCurrentSpeed(port.getCurrSpeed());
    fcncub.setHardwareAddress(port.getHwAddr());
    fcncub.setMaximumSpeed(port.getMaxSpeed());
    fcncub.setName(port.getName());
    fcncub.setPortNumber(OpenflowPortsUtil.getProtocolAgnosticPort(ofVersion, portNumber));
    builder.addAugmentation(FlowCapableNodeConnectorUpdated.class, fcncub.build());
    return builder.build();
}
Also used : OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) PortStatusMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage) FlowCapableNodeConnectorUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdatedBuilder) NodeConnectorUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdatedBuilder) FlowCapableNodeConnectorUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdatedBuilder)

Example 4 with NodeConnectorUpdated

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated in project openflowplugin by opendaylight.

the class NodeConnectorNotificationSupplierImplTest method testCreate.

@Test
public void testCreate() {
    final NodeConnectorUpdated notification = notifSupplierImpl.createNotification(createTestFlowCapableNodeConnecor(), createTestFlowCapableConnectorNodePath());
    assertNotNull(notification);
    assertEquals(FLOW_CODE_CONNECTOR_ID, notification.getId().getValue());
    assertEquals(FLOW_CODE_CONNECTOR_ID, notification.getNodeConnectorRef().getValue().firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue());
    assertEquals(FLOW_NODE_ID, notification.getNodeConnectorRef().getValue().firstKeyOf(Node.class, NodeKey.class).getId().getValue());
}
Also used : FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeConnectorUpdated(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 FlowCapableNodeConnectorUpdatedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdatedBuilder)2 NodeConnectorUpdated (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated)2 NodeConnectorUpdatedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdatedBuilder)2 BigInteger (java.math.BigInteger)1 OpenflowVersion (org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)1 FlowCapableNodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector)1 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)1 NodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector)1 NodeConnectorKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)1 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)1 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)1 PortGrouping (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping)1 PortStatusMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage)1