2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.ovsdb.southbound.transactions.md;
11 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
12 import java.util.ArrayList;
13 import java.util.HashMap;
14 import java.util.List;
16 import java.util.NoSuchElementException;
17 import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
18 import org.opendaylight.ovsdb.lib.message.TableUpdates;
19 import org.opendaylight.ovsdb.lib.notation.Version;
20 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
21 import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec;
22 import org.opendaylight.ovsdb.southbound.OvsdbConnectionInstance;
23 import org.opendaylight.ovsdb.southbound.SouthboundConstants;
24 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
25 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
29 public class OvsdbOperationalCommandAggregator implements TransactionCommand {
31 private static final Logger LOG = LoggerFactory.getLogger(OvsdbOperationalCommandAggregator.class);
32 private final List<TransactionCommand> commands = new ArrayList<>();
33 private final Map<NodeId, Node> updatedBridgeNodes = new HashMap<>();
35 public OvsdbOperationalCommandAggregator(InstanceIdentifierCodec instanceIdentifierCodec,
36 OvsdbConnectionInstance key, TableUpdates updates, DatabaseSchema dbSchema, boolean initialUpdate) {
37 commands.add(new OpenVSwitchUpdateCommand(instanceIdentifierCodec, key, updates, dbSchema));
38 commands.add(new OvsdbManagersUpdateCommand(key, updates, dbSchema));
39 commands.add(new OvsdbManagersRemovedCommand(key, updates, dbSchema));
40 commands.add(new OvsdbQosUpdateCommand(instanceIdentifierCodec, key, updates, dbSchema));
41 commands.add(new OvsdbQosRemovedCommand(key, updates, dbSchema));
42 commands.add(new OvsdbQueueUpdateCommand(instanceIdentifierCodec, key, updates, dbSchema));
43 commands.add(new OvsdbQueueRemovedCommand(key, updates, dbSchema));
44 commands.add(new OvsdbBridgeUpdateCommand(instanceIdentifierCodec, key, updates, dbSchema,
46 commands.add(new OvsdbBridgeRemovedCommand(instanceIdentifierCodec, key, updates, dbSchema));
47 commands.add(new OvsdbControllerUpdateCommand(key, updates, dbSchema));
48 commands.add(new OvsdbControllerRemovedCommand(instanceIdentifierCodec, key, updates, dbSchema));
50 commands.add(new OvsdbInitialPortUpdateCommand(instanceIdentifierCodec, key, updates, dbSchema,
53 commands.add(new OvsdbPortUpdateCommand(instanceIdentifierCodec, key, updates, dbSchema));
55 commands.add(new OvsdbPortRemoveCommand(instanceIdentifierCodec, key, updates, dbSchema));
57 if (dbSchema.getVersion().compareTo(
58 Version.fromString(SouthboundConstants.AUTOATTACH_SUPPORTED_OVS_SCHEMA_VERSION)) >= 0) {
59 commands.add(new OvsdbAutoAttachUpdateCommand(key, updates, dbSchema));
60 commands.add(new OvsdbAutoAttachRemovedCommand(key, updates, dbSchema));
62 LOG.debug("UNSUPPORTED FUNCTIONALITY: AutoAttach not supported in OVS schema version {}",
63 dbSchema.getVersion().toString());
67 @SuppressFBWarnings("DCN_NULLPOINTER_EXCEPTION")
69 public void execute(ReadWriteTransaction transaction) {
70 for (TransactionCommand command : commands) {
72 command.execute(transaction);
73 } catch (NullPointerException | NoSuchElementException | ClassCastException e) {
74 LOG.warn("Exception trying to execute {}", command, e);
80 public void onSuccess() {
81 for (TransactionCommand command : commands) {
87 public void onFailure(Throwable throwable) {
88 for (TransactionCommand command: commands) {
89 command.onFailure(throwable);