Search in sources :

Example 1 with NodeName

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.NodeName in project netvirt by opendaylight.

the class IfMgr method transmitRouterAdvertisement.

private void transmitRouterAdvertisement(VirtualPort intf, Ipv6RtrAdvertType advType) {
    Ipv6RouterAdvt ipv6RouterAdvert = new Ipv6RouterAdvt(packetService);
    LOG.debug("in transmitRouterAdvertisement for {}", advType);
    VirtualNetwork vnet = getNetwork(intf.getNetworkID());
    if (vnet != null) {
        String nodeName;
        String outPort;
        Collection<VirtualNetwork.DpnInterfaceInfo> dpnIfaceList = vnet.getDpnIfaceList();
        for (VirtualNetwork.DpnInterfaceInfo dpnIfaceInfo : dpnIfaceList) {
            nodeName = Ipv6Constants.OPENFLOW_NODE_PREFIX + dpnIfaceInfo.getDpId();
            List<NodeConnectorRef> ncRefList = new ArrayList<>();
            for (Long ofPort : dpnIfaceInfo.ofPortList) {
                outPort = nodeName + ":" + ofPort;
                LOG.debug("Transmitting RA {} for node {}, port {}", advType, nodeName, outPort);
                InstanceIdentifier<NodeConnector> outPortId = InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId(nodeName))).child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId(outPort))).build();
                ncRefList.add(new NodeConnectorRef(outPortId));
            }
            if (!ncRefList.isEmpty()) {
                ipv6RouterAdvert.transmitRtrAdvertisement(advType, intf, ncRefList, null);
            }
        }
    }
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) ArrayList(java.util.ArrayList) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) IVirtualNetwork(org.opendaylight.netvirt.ipv6service.api.IVirtualNetwork) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)

Example 2 with NodeName

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.NodeName in project genius by opendaylight.

the class ItmManagerRpcService method getDpnIdByComputeNodeNameFromOpInventoryNodes.

private Map<String, BigInteger> getDpnIdByComputeNodeNameFromOpInventoryNodes(List<String> nodeNames) throws ReadFailedException {
    Nodes operInventoryNodes = singleTransactionDataBroker.syncRead(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(Nodes.class).build());
    if (operInventoryNodes.getNode() == null || operInventoryNodes.getNode().isEmpty()) {
        throw new IllegalStateException("Failed to find operational inventory nodes datastore");
    }
    Map<String, BigInteger> result = new HashMap<>();
    for (Node node : operInventoryNodes.getNode()) {
        String name = node.getAugmentation(FlowCapableNode.class).getDescription();
        if (nodeNames.contains(name)) {
            String[] nodeId = node.getId().getValue().split(":");
            result.put(name, new BigInteger(nodeId[1]));
        }
    }
    for (String nodeName : nodeNames) {
        if (!result.containsKey(nodeName)) {
            throw new IllegalStateException("Failed to find dpn id of compute node name from oper inventory " + nodeName);
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) BigInteger(java.math.BigInteger) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)

Example 3 with NodeName

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.NodeName in project controller by opendaylight.

the class AkkaEntityOwnershipServiceTest method testEntityRetrievalWithYiid.

@Test
public void testEntityRetrievalWithYiid() throws Exception {
    final YangInstanceIdentifier entityId = YangInstanceIdentifier.create(new NodeIdentifier(NetworkTopology.QNAME), new NodeIdentifier(Topology.QNAME), NodeIdentifierWithPredicates.of(Topology.QNAME, QName.create(Topology.QNAME, "topology-id"), "test"), new NodeIdentifier(Node.QNAME), NodeIdentifierWithPredicates.of(Node.QNAME, QName.create(Node.QNAME, "node-id"), "test://test-node"));
    final DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
    final DOMEntityOwnershipCandidateRegistration reg = service.registerCandidate(entity);
    verifyEntityOwnershipCandidateRegistration(entity, reg);
    verifyEntityCandidateRegistered(ENTITY_TYPE, entityId, "member-1");
    RpcResult<GetEntityOutput> getEntityResult = service.getEntity(new GetEntityInputBuilder().setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId))).setType(new EntityType(ENTITY_TYPE)).build()).get();
    assertEquals(getEntityResult.getResult().getOwnerNode().getValue(), "member-1");
    assertEquals(getEntityResult.getResult().getCandidateNodes().get(0).getValue(), "member-1");
    // we should not be able to retrieve the entity when using string
    final String entityPathEncoded = "/network-topology:network-topology/topology[topology-id='test']/node[node-id='test://test-node']";
    getEntityResult = service.getEntity(new GetEntityInputBuilder().setName(new EntityName(entityPathEncoded)).setType(new EntityType(ENTITY_TYPE)).build()).get();
    assertNull(getEntityResult.getResult().getOwnerNode());
    assertTrue(getEntityResult.getResult().getCandidateNodes().isEmpty());
    final GetEntitiesOutput getEntitiesResult = service.getEntities(new GetEntitiesInputBuilder().build()).get().getResult();
    assertEquals(getEntitiesResult.getEntities().size(), 1);
    assertTrue(getEntitiesResult.getEntities().get(new EntitiesKey(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)), new EntityType(ENTITY_TYPE))).getCandidateNodes().contains(new NodeName("member-1")));
    assertTrue(getEntitiesResult.getEntities().get(new EntitiesKey(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)), new EntityType(ENTITY_TYPE))).getOwnerNode().getValue().equals("member-1"));
    final GetEntityOwnerOutput getOwnerResult = service.getEntityOwner(new GetEntityOwnerInputBuilder().setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId))).setType(new EntityType(ENTITY_TYPE)).build()).get().getResult();
    assertEquals(getOwnerResult.getOwnerNode().getValue(), "member-1");
}
Also used : GetEntityOwnerInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityOwnerInputBuilder) DOMEntityOwnershipCandidateRegistration(org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipCandidateRegistration) EntityName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityName) NodeName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.NodeName) DOMEntity(org.opendaylight.mdsal.eos.dom.api.DOMEntity) EntitiesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.get.entities.output.EntitiesKey) GetEntityOwnerOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityOwnerOutput) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) GetEntityInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityInputBuilder) EntityType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityType) GetEntityOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityOutput) GetEntitiesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntitiesInputBuilder) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) GetEntitiesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntitiesOutput) Test(org.junit.Test)

Example 4 with NodeName

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.NodeName in project controller by opendaylight.

the class EntityRpcHandlerTest method testEntityRetrievalWithUnavailableSupervisor.

/*
     * Tests entity rpcs handled both by the owner supervisor(service1) and with an idle supervisor(falling
     * back to distributed-data in an inactive datacenter). This covers both the available cases, datacenters and case
     * in which the node with active akka-singleton is shutdown and another one takes over.
     */
@Test
public void testEntityRetrievalWithUnavailableSupervisor() throws Exception {
    final YangInstanceIdentifier entityId = YangInstanceIdentifier.create(new NodeIdentifier(NetworkTopology.QNAME), new NodeIdentifier(Topology.QNAME), NodeIdentifierWithPredicates.of(Topology.QNAME, QName.create(Topology.QNAME, "topology-id"), "test"), new NodeIdentifier(Node.QNAME), NodeIdentifierWithPredicates.of(Node.QNAME, QName.create(Node.QNAME, "node-id"), "test://test-node"));
    final DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
    final DOMEntityOwnershipCandidateRegistration reg = service1.registerCandidate(entity);
    await().untilAsserted(() -> {
        final RpcResult<GetEntityOutput> getEntityResult = service1.getEntity(new GetEntityInputBuilder().setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId))).setType(new EntityType(ENTITY_TYPE)).build()).get();
        assertEquals(getEntityResult.getResult().getOwnerNode().getValue(), "member-1");
        assertEquals(getEntityResult.getResult().getCandidateNodes().get(0).getValue(), "member-1");
    });
    // keep this under ask timeout to make sure the singleton actor in the inactive datacenter responds with failure
    // immediately, so that the rpc actor retries with distributed-data asap
    await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> {
        final GetEntitiesOutput getEntitiesResult = service2.getEntities(new GetEntitiesInputBuilder().build()).get().getResult();
        assertEquals(getEntitiesResult.getEntities().size(), 1);
        assertTrue(getEntitiesResult.getEntities().get(new EntitiesKey(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)), new EntityType(ENTITY_TYPE))).getCandidateNodes().contains(new NodeName("member-1")));
        assertTrue(getEntitiesResult.getEntities().get(new EntitiesKey(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)), new EntityType(ENTITY_TYPE))).getOwnerNode().getValue().equals("member-1"));
    });
    await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> {
        final GetEntityOutput getEntityResult = service2.getEntity(new GetEntityInputBuilder().setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId))).setType(new EntityType(ENTITY_TYPE)).build()).get().getResult();
        assertEquals(getEntityResult.getOwnerNode().getValue(), "member-1");
        assertEquals(getEntityResult.getCandidateNodes().get(0).getValue(), "member-1");
    });
    await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> {
        final GetEntityOwnerOutput getOwnerResult = service2.getEntityOwner(new GetEntityOwnerInputBuilder().setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId))).setType(new EntityType(ENTITY_TYPE)).build()).get().getResult();
        assertEquals(getOwnerResult.getOwnerNode().getValue(), "member-1");
    });
}
Also used : GetEntityOwnerInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityOwnerInputBuilder) DOMEntityOwnershipCandidateRegistration(org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipCandidateRegistration) EntityName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityName) NodeName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.NodeName) DOMEntity(org.opendaylight.mdsal.eos.dom.api.DOMEntity) EntitiesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.get.entities.output.EntitiesKey) GetEntityOwnerOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityOwnerOutput) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) GetEntityInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityInputBuilder) EntityType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityType) GetEntityOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityOutput) GetEntitiesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntitiesInputBuilder) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) GetEntitiesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntitiesOutput) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 DOMEntity (org.opendaylight.mdsal.eos.dom.api.DOMEntity)2 DOMEntityOwnershipCandidateRegistration (org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipCandidateRegistration)2 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)2 EntityName (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityName)2 EntityType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityType)2 GetEntitiesInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntitiesInputBuilder)2 GetEntitiesOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntitiesOutput)2 GetEntityInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityInputBuilder)2 GetEntityOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityOutput)2 GetEntityOwnerInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityOwnerInputBuilder)2 GetEntityOwnerOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityOwnerOutput)2 NodeName (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.NodeName)2 EntitiesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.get.entities.output.EntitiesKey)2 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)2 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)2 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 IVirtualNetwork (org.opendaylight.netvirt.ipv6service.api.IVirtualNetwork)1