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
8 package org.opendaylight.ovsdb.southbound.transactions.md;
12 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
13 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
14 import org.opendaylight.ovsdb.lib.message.TableUpdates;
15 import org.opendaylight.ovsdb.lib.notation.UUID;
16 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
17 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
18 import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
19 import org.opendaylight.ovsdb.schema.openvswitch.Controller;
20 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntry;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
24 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
26 public class OvsdbControllerUpdateCommand extends AbstractTransactionCommand {
30 private Map<UUID, Controller> updatedControllerRows;
31 private Map<UUID, Bridge> updatedBridgeRows;
33 public OvsdbControllerUpdateCommand(ConnectionInfo key,
34 TableUpdates updates, DatabaseSchema dbSchema) {
35 super(key, updates, dbSchema);
36 updatedBridgeRows = TyperUtils.extractRowsUpdated(Bridge.class, getUpdates(), getDbSchema());
37 updatedControllerRows = TyperUtils.extractRowsUpdated(Controller.class,
38 getUpdates(), getDbSchema());
42 public void execute(ReadWriteTransaction transaction) {
43 for (Bridge bridge: updatedBridgeRows.values()) {
44 setController(transaction, bridge);
49 private void setController(ReadWriteTransaction transaction, Bridge bridge) {
50 for (ControllerEntry controllerEntry: SouthboundMapper.createControllerEntries(bridge, updatedControllerRows)) {
51 InstanceIdentifier<ControllerEntry> iid =
52 SouthboundMapper.createInstanceIdentifier(getConnectionInfo(), bridge)
53 .augmentation(OvsdbBridgeAugmentation.class)
54 .child(ControllerEntry.class,controllerEntry.getKey());
55 transaction.put(LogicalDatastoreType.OPERATIONAL, iid, controllerEntry);