Search in sources :

Example 86 with Node

use of org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.node.data.Node in project controller by opendaylight.

the class ClusterAdminRpcServiceTest method testBackupDatastore.

@Test
public void testBackupDatastore() throws Exception {
    MemberNode node = MemberNode.builder(memberNodes).akkaConfig("Member1").moduleShardsConfig("module-shards-member1.conf").waitForShardLeader("cars", "people").testName("testBackupDatastore").build();
    String fileName = "target/testBackupDatastore";
    new File(fileName).delete();
    final ClusterAdminRpcService service = new ClusterAdminRpcService(node.configDataStore(), node.operDataStore(), null, null);
    RpcResult<BackupDatastoreOutput> rpcResult = service.backupDatastore(new BackupDatastoreInputBuilder().setFilePath(fileName).build()).get(5, TimeUnit.SECONDS);
    verifySuccessfulRpcResult(rpcResult);
    try (FileInputStream fis = new FileInputStream(fileName)) {
        List<DatastoreSnapshot> snapshots = SerializationUtils.deserialize(fis);
        assertEquals("DatastoreSnapshot size", 2, snapshots.size());
        ImmutableMap<String, DatastoreSnapshot> map = ImmutableMap.of(snapshots.get(0).getType(), snapshots.get(0), snapshots.get(1).getType(), snapshots.get(1));
        verifyDatastoreSnapshot(node.configDataStore().getActorUtils().getDataStoreName(), map.get(node.configDataStore().getActorUtils().getDataStoreName()), "cars", "people");
    } finally {
        new File(fileName).delete();
    }
    // Test failure by killing a shard.
    node.configDataStore().getActorUtils().getShardManager().tell(node.datastoreContextBuilder().shardInitializationTimeout(200, TimeUnit.MILLISECONDS).build(), ActorRef.noSender());
    ActorRef carsShardActor = node.configDataStore().getActorUtils().findLocalShard("cars").get();
    node.kit().watch(carsShardActor);
    carsShardActor.tell(PoisonPill.getInstance(), ActorRef.noSender());
    node.kit().expectTerminated(carsShardActor);
    rpcResult = service.backupDatastore(new BackupDatastoreInputBuilder().setFilePath(fileName).build()).get(5, TimeUnit.SECONDS);
    assertFalse("isSuccessful", rpcResult.isSuccessful());
    assertEquals("getErrors", 1, rpcResult.getErrors().size());
}
Also used : MemberNode(org.opendaylight.controller.cluster.datastore.MemberNode) BackupDatastoreOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.BackupDatastoreOutput) ActorRef(akka.actor.ActorRef) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) DatastoreSnapshot(org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot) File(java.io.File) BackupDatastoreInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.BackupDatastoreInputBuilder) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 87 with Node

use of org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.node.data.Node in project netvirt by opendaylight.

the class ElanServiceProvider method handleExternalElanNetwork.

private void handleExternalElanNetwork(ElanInstance elanInstance, boolean update, BiFunction<ElanInstance, String, Void> function) {
    String elanInstanceName = elanInstance.getElanInstanceName();
    boolean isFlatOrVlanNetwork = (ElanUtils.isFlat(elanInstance) || ElanUtils.isVlan(elanInstance));
    if (!isFlatOrVlanNetwork) {
        LOG.error("Network is not of type FLAT/VLAN." + "Ignoring Elan-interface creation for given ProviderInterface {}", elanInstance.getPhysicalNetworkName());
        return;
    }
    if (elanInstance.getPhysicalNetworkName() == null) {
        LOG.trace("No physical network attached to {}", elanInstanceName);
        return;
    }
    Map<NodeKey, Node> nodes = southboundUtils.getOvsdbNodes();
    if (nodes == null || nodes.isEmpty()) {
        LOG.trace("No OVS nodes found while creating external network for ELAN {}", elanInstance.getElanInstanceName());
        return;
    }
    for (Node node : nodes.values()) {
        if (bridgeMgr.isIntegrationBridge(node)) {
            if (update && !elanInstance.isExternal()) {
                DpnInterfaces dpnInterfaces = elanUtils.getElanInterfaceInfoByElanDpn(elanInstanceName, bridgeMgr.getDatapathId(node));
                if (dpnInterfaces == null || dpnInterfaces.getInterfaces().isEmpty()) {
                    continue;
                }
            }
            String interfaceName = bridgeMgr.getProviderInterfaceName(node, elanInstance.getPhysicalNetworkName());
            function.apply(elanInstance, interfaceName);
        }
    }
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)

Example 88 with Node

use of org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.node.data.Node in project netvirt by opendaylight.

the class HwvtepHAUtil method convertLocatorRef.

/**
 * Trnaform locator reference to nodepath passed .
 *
 * @param src {@link HwvtepPhysicalLocatorRef} Logical Switch Ref which needs to be transformed
 * @param nodePath {@link InstanceIdentifier} src needs to be transformed to this path
 * @return physicalLocatorRef {@link HwvtepPhysicalLocatorRef} the transforrmed result
 */
public static HwvtepPhysicalLocatorRef convertLocatorRef(HwvtepPhysicalLocatorRef src, InstanceIdentifier<Node> nodePath) {
    InstanceIdentifier<TerminationPoint> srcTepPath = (InstanceIdentifier<TerminationPoint>) src.getValue();
    TpId tpId = srcTepPath.firstKeyOf(TerminationPoint.class).getTpId();
    InstanceIdentifier<TerminationPoint> tpPath = nodePath.child(TerminationPoint.class, new TerminationPointKey(tpId));
    HwvtepPhysicalLocatorRef physicalLocatorRef = new HwvtepPhysicalLocatorRef(tpPath);
    return physicalLocatorRef;
}
Also used : TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) HwvtepPhysicalLocatorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorRef) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 89 with Node

use of org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.node.data.Node in project netvirt by opendaylight.

the class HwvtepHAUtil method convertLogicalSwitchRef.

/**
 * Trnaform logical switch to nodepath passed .
 *
 * @param src {@link HwvtepLogicalSwitchRef} Logical Switch Ref which needs to be transformed
 * @param nodePath {@link InstanceIdentifier} src needs to be transformed to this path
 * @return ref {@link HwvtepLogicalSwitchRef} the transforrmed result
 */
public static HwvtepLogicalSwitchRef convertLogicalSwitchRef(HwvtepLogicalSwitchRef src, InstanceIdentifier<Node> nodePath) {
    InstanceIdentifier<LogicalSwitches> srcId = (InstanceIdentifier<LogicalSwitches>) src.getValue();
    HwvtepNodeName switchName = srcId.firstKeyOf(LogicalSwitches.class).getHwvtepNodeName();
    InstanceIdentifier<LogicalSwitches> iid = nodePath.augmentation(HwvtepGlobalAugmentation.class).child(LogicalSwitches.class, new LogicalSwitchesKey(switchName));
    HwvtepLogicalSwitchRef ref = new HwvtepLogicalSwitchRef(iid);
    return ref;
}
Also used : LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) HwvtepLogicalSwitchRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef) HwvtepNodeName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName) LogicalSwitchesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitchesKey)

Example 90 with Node

use of org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.node.data.Node in project netvirt by opendaylight.

the class HwvtepHAUtil method buildManagersForHANode.

/**
 * Transform child managers (Source) to HA managers using HA node path.
 *
 * @param childNode Child Node
 * @param haGlobalCfg HA global config node
 * @return Transformed managers
 */
public static List<Managers> buildManagersForHANode(Node childNode, Optional<Node> haGlobalCfg) {
    Set<NodeId> nodeIds = new HashSet<>();
    nodeIds.add(childNode.getNodeId());
    List<NodeId> childNodeIds = getChildNodeIdsFromManagerOtherConfig(haGlobalCfg);
    nodeIds.addAll(childNodeIds);
    InstanceIdentifier<Node> parentIid = HwvtepHACache.getInstance().getParent(convertToInstanceIdentifier(childNode.getNodeId().getValue()));
    HwvtepHACache.getInstance().getChildrenForHANode(parentIid).stream().forEach(iid -> nodeIds.add(iid.firstKeyOf(Node.class).getNodeId()));
    ManagersBuilder builder1 = new ManagersBuilder();
    builder1.withKey(new ManagersKey(new Uri(MANAGER_KEY)));
    List<ManagerOtherConfigs> otherConfigses = new ArrayList<>();
    String children = nodeIds.stream().map(NodeId::getValue).collect(Collectors.joining(","));
    otherConfigses.add(getOtherConfigBuilder(HA_CHILDREN, children).build());
    builder1.setManagerOtherConfigs(otherConfigses);
    List<Managers> managers = new ArrayList<>();
    managers.add(builder1.build());
    return managers;
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ArrayList(java.util.ArrayList) ManagersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.ManagersBuilder) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) ManagerOtherConfigs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.managers.ManagerOtherConfigs) Managers(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Managers) ManagersKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.ManagersKey) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) HashSet(java.util.HashSet)

Aggregations

Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)220 ArrayList (java.util.ArrayList)160 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)160 Test (org.junit.Test)115 ExecutionException (java.util.concurrent.ExecutionException)108 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)108 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)105 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)93 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)89 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)88 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)81 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)61 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)60 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)60 List (java.util.List)59 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)57 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)54 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)53 HwvtepGlobalAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation)53 Logger (org.slf4j.Logger)52