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 java.util.ArrayList;
12 import java.util.HashMap;
13 import java.util.List;
15 import java.util.NoSuchElementException;
16 import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
17 import org.opendaylight.ovsdb.lib.message.TableUpdates;
18 import org.opendaylight.ovsdb.lib.notation.Version;
19 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
20 import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec;
21 import org.opendaylight.ovsdb.southbound.OvsdbConnectionInstance;
22 import org.opendaylight.ovsdb.southbound.SouthboundConstants;
23 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
24 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
28 public class OvsdbOperationalCommandAggregator implements TransactionCommand {
30 private static final Logger LOG = LoggerFactory.getLogger(OvsdbOperationalCommandAggregator.class);
31 private final List<TransactionCommand> commands = new ArrayList<>();
32 private final Map<NodeId, Node> updatedBridgeNodes = new HashMap<>();
33 private boolean initialUpdate;
35 public OvsdbOperationalCommandAggregator(InstanceIdentifierCodec instanceIdentifierCodec,
36 OvsdbConnectionInstance key, TableUpdates updates, DatabaseSchema dbSchema, boolean initialUpdate) {
37 this.initialUpdate = initialUpdate;
38 commands.add(new OpenVSwitchUpdateCommand(instanceIdentifierCodec, key, updates, dbSchema));
39 commands.add(new OvsdbManagersUpdateCommand(key, updates, dbSchema));
40 commands.add(new OvsdbManagersRemovedCommand(key, updates, dbSchema));
41 commands.add(new OvsdbQosUpdateCommand(instanceIdentifierCodec, key, updates, dbSchema));
42 commands.add(new OvsdbQosRemovedCommand(key, updates, dbSchema));
43 commands.add(new OvsdbQueueUpdateCommand(instanceIdentifierCodec, key, updates, dbSchema));
44 commands.add(new OvsdbQueueRemovedCommand(key, updates, dbSchema));
45 commands.add(new OvsdbBridgeUpdateCommand(instanceIdentifierCodec, key, updates, dbSchema,
47 commands.add(new OvsdbBridgeRemovedCommand(instanceIdentifierCodec, key, updates, dbSchema));
48 commands.add(new OvsdbControllerUpdateCommand(key, updates, dbSchema));
49 commands.add(new OvsdbControllerRemovedCommand(instanceIdentifierCodec, key, updates, dbSchema));
51 commands.add(new OvsdbInitialPortUpdateCommand(instanceIdentifierCodec, key, updates, dbSchema,
54 commands.add(new OvsdbPortUpdateCommand(instanceIdentifierCodec, key, updates, dbSchema));
56 commands.add(new OvsdbPortRemoveCommand(instanceIdentifierCodec, key, updates, dbSchema));
58 if (dbSchema.getVersion().compareTo(
59 Version.fromString(SouthboundConstants.AUTOATTACH_SUPPORTED_OVS_SCHEMA_VERSION)) >= 0) {
60 commands.add(new OvsdbAutoAttachUpdateCommand(key, updates, dbSchema));
61 commands.add(new OvsdbAutoAttachRemovedCommand(key, updates, dbSchema));
63 LOG.debug("UNSUPPORTED FUNCTIONALITY: AutoAttach not supported in OVS schema version {}",
64 dbSchema.getVersion().toString());
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);