529fabaab707a078be99ef70033b02a4558f82d9
[ovsdb.git] / southbound / southbound-impl / src / main / java / org / opendaylight / ovsdb / southbound / transactions / md / OvsdbOperationalCommandAggregator.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.ovsdb.southbound.transactions.md;
10
11 import java.util.ArrayList;
12 import java.util.List;
13
14 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
15 import org.opendaylight.ovsdb.lib.message.TableUpdates;
16 import org.opendaylight.ovsdb.lib.notation.Version;
17 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
18 import org.opendaylight.ovsdb.southbound.OvsdbConnectionInstance;
19 import org.opendaylight.ovsdb.southbound.SouthboundConstants;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 public class OvsdbOperationalCommandAggregator implements TransactionCommand {
24
25     private static final Logger LOG = LoggerFactory.getLogger(OvsdbOperationalCommandAggregator.class);
26     private List<TransactionCommand> commands = new ArrayList<>();
27
28     public OvsdbOperationalCommandAggregator(OvsdbConnectionInstance key,TableUpdates updates,
29             DatabaseSchema dbSchema) {
30         commands.add(new OpenVSwitchUpdateCommand(key, updates, dbSchema));
31         commands.add(new OvsdbManagersUpdateCommand(key, updates,  dbSchema));
32         commands.add(new OvsdbManagersRemovedCommand(key, updates,  dbSchema));
33         commands.add(new OvsdbQosUpdateCommand(key, updates,  dbSchema));
34         commands.add(new OvsdbQosRemovedCommand(key, updates,  dbSchema));
35         commands.add(new OvsdbQueueUpdateCommand(key, updates,  dbSchema));
36         commands.add(new OvsdbQueueRemovedCommand(key, updates,  dbSchema));
37         commands.add(new OvsdbBridgeUpdateCommand(key, updates,  dbSchema));
38         commands.add(new OvsdbBridgeRemovedCommand(key, updates,  dbSchema));
39         commands.add(new OvsdbControllerUpdateCommand(key, updates,  dbSchema));
40         commands.add(new OvsdbControllerRemovedCommand(key, updates,  dbSchema));
41         commands.add(new OvsdbPortUpdateCommand(key, updates, dbSchema));
42         commands.add(new OvsdbPortRemoveCommand(key, updates, dbSchema));
43
44         if(dbSchema.getVersion().compareTo(Version.fromString(SouthboundConstants.AUTOATTACH_SUPPORTED_OVS_SCHEMA_VERSION)) >= 0) {
45             commands.add(new OvsdbAutoAttachUpdateCommand(key, updates, dbSchema));
46             commands.add(new OvsdbAutoAttachRemovedCommand(key, updates, dbSchema));
47         } else {
48             LOG.debug("UNSUPPORTED FUNCTIONALITY: AutoAttach not supported in OVS schema version {}", dbSchema.getVersion().toString());
49         }
50     }
51
52     @Override
53     public void execute(ReadWriteTransaction transaction) {
54         for (TransactionCommand command: commands) {
55             command.execute(transaction);
56         }
57     }
58 }