import java.util.Map.Entry;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.ovsdb.lib.notation.Mutator;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
-import org.opendaylight.ovsdb.schema.openvswitch.Controller;
import org.opendaylight.ovsdb.schema.openvswitch.Interface;
-import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
import org.opendaylight.ovsdb.schema.openvswitch.Port;
import org.opendaylight.ovsdb.southbound.SouthboundConstants;
import org.opendaylight.ovsdb.southbound.SouthboundMapper;
import org.opendaylight.ovsdb.southbound.SouthboundUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeInternal;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.Sets;
-public class BridgeCreateCommand implements TransactCommand {
- private AsyncDataChangeEvent<InstanceIdentifier<?>, OvsdbBridgeAugmentation> changes;
- private static final Logger LOG = LoggerFactory.getLogger(BridgeCreateCommand.class);
+public class BridgeCreateCommand extends AbstractTransactCommand {
+ private static final Logger LOG = LoggerFactory.getLogger(BridgeCreateCommand.class);
- public BridgeCreateCommand(AsyncDataChangeEvent<InstanceIdentifier<?>, OvsdbBridgeAugmentation> changes) {
- this.changes = changes;
+ public BridgeCreateCommand(BridgeOperationalState state,
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
+ super(state, changes);
}
+
+
@Override
public void execute(TransactionBuilder transaction) {
- Map<InstanceIdentifier<Node>, OvsdbBridgeAugmentation> created =
- TransactUtils.extractOvsdbManagedNodeCreate(changes);
- for (Entry<InstanceIdentifier<Node>, OvsdbBridgeAugmentation> ovsdbManagedNodeEntry:
+ Map<InstanceIdentifier<OvsdbBridgeAugmentation>, OvsdbBridgeAugmentation> created =
+ TransactUtils.extractCreated(getChanges(),OvsdbBridgeAugmentation.class);
+ for (Entry<InstanceIdentifier<OvsdbBridgeAugmentation>, OvsdbBridgeAugmentation> ovsdbManagedNodeEntry:
created.entrySet()) {
OvsdbBridgeAugmentation ovsdbManagedNode = ovsdbManagedNodeEntry.getValue();
LOG.debug("Received request to create ovsdb bridge name: {} uuid: {}",
&& SouthboundMapper.createOvsdbBridgeProtocols(ovsdbManagedNode).size() > 0) {
bridge.setProtocols(SouthboundMapper.createOvsdbBridgeProtocols(ovsdbManagedNode));
}
- Map<UUID,Controller> controllerMap = SouthboundMapper.createOvsdbController(
- ovsdbManagedNode, transaction.getDatabaseSchema());
- for (Entry<UUID,Controller> entry: controllerMap.entrySet()) {
- transaction.add(op.insert(entry.getValue()).withId(entry.getKey().toString()));
- }
- if (!controllerMap.isEmpty()) {
- bridge.setController(controllerMap.keySet());
- }
bridge.setPorts(Sets.newHashSet(new UUID(portNamedUuid)));
// Set the iid external_id
bridge.setExternalIds(externalIds);
transaction.add(op.insert(bridge).withId(bridgeNamedUuid));
-
- // OpenVSwitchPart
- OpenVSwitch ovs = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), OpenVSwitch.class);
- ovs.setBridges(Sets.newHashSet(new UUID(bridgeNamedUuid)));
- transaction.add(op.mutate(ovs).addMutation(ovs.getBridgesColumn().getSchema(),
- Mutator.INSERT,
- ovs.getBridgesColumn().getData()));
}
}