import static org.opendaylight.ovsdb.lib.operations.Operations.op;
-import com.google.common.base.Optional;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import java.util.Optional;
+import org.opendaylight.mdsal.binding.api.DataTreeModification;
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.southbound.InstanceIdentifierCodec;
private static final Logger LOG = LoggerFactory.getLogger(ControllerUpdateCommand.class);
@Override
- public void execute(TransactionBuilder transaction, BridgeOperationalState state,
- DataChangeEvent events, InstanceIdentifierCodec instanceIdentifierCodec) {
+ public void execute(final TransactionBuilder transaction, final BridgeOperationalState state,
+ final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) {
execute(transaction, state, TransactUtils.extractCreatedOrUpdated(events, ControllerEntry.class),
TransactUtils.extractCreatedOrUpdated(events, OvsdbBridgeAugmentation.class));
}
@Override
- public void execute(TransactionBuilder transaction, BridgeOperationalState state,
- Collection<DataTreeModification<Node>> modifications, InstanceIdentifierCodec instanceIdentifierCodec) {
+ public void execute(final TransactionBuilder transaction, final BridgeOperationalState state,
+ final Collection<DataTreeModification<Node>> modifications,
+ final InstanceIdentifierCodec instanceIdentifierCodec) {
execute(transaction, state, TransactUtils.extractCreatedOrUpdated(modifications, ControllerEntry.class),
TransactUtils.extractCreatedOrUpdated(modifications, OvsdbBridgeAugmentation.class));
}
- private void execute(TransactionBuilder transaction, BridgeOperationalState state,
- Map<InstanceIdentifier<ControllerEntry>, ControllerEntry> controllers,
- Map<InstanceIdentifier<OvsdbBridgeAugmentation>, OvsdbBridgeAugmentation> bridges) {
+ private static void execute(final TransactionBuilder transaction, final BridgeOperationalState state,
+ final Map<InstanceIdentifier<ControllerEntry>, ControllerEntry> controllers,
+ final Map<InstanceIdentifier<OvsdbBridgeAugmentation>, OvsdbBridgeAugmentation> bridges) {
LOG.info("Register ODL controllers : {} bridges detail : {}",
controllers, bridges);
for (Entry<InstanceIdentifier<ControllerEntry>, ControllerEntry> entry: controllers.entrySet()) {
entry.getKey().firstIdentifierOf(OvsdbBridgeAugmentation.class);
Optional<OvsdbBridgeAugmentation> bridgeOptional =
state.getOvsdbBridgeAugmentation(bridgeIid);
- OvsdbBridgeAugmentation ovsdbBridge = bridgeOptional.or(bridges.get(bridgeIid));
+ OvsdbBridgeAugmentation ovsdbBridge = bridgeOptional.isPresent()
+ ? bridgeOptional.orElseThrow() : bridges.get(bridgeIid);
if (ovsdbBridge != null
&& ovsdbBridge.getBridgeName() != null
&& entry.getValue() != null
&& entry.getValue().getTarget() != null) {
ControllerEntry controllerEntry = entry.getValue();
- Controller controller =
- TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Controller.class);
+ Controller controller = transaction.getTypedRowWrapper(Controller.class);
controller.setTarget(controllerEntry.getTarget().getValue());
if (controllerEntry.getMaxBackoff() != null) {
- controller.setMaxBackoff(Collections.singleton(controllerEntry.getMaxBackoff()));
+ controller.setMaxBackoff(Collections.singleton(controllerEntry.getMaxBackoff().toJava()));
}
if (controllerEntry.getInactivityProbe() != null) {
- controller.setInactivityProbe(Collections.singleton(controllerEntry.getInactivityProbe()));
+ controller.setInactivityProbe(Collections.singleton(
+ controllerEntry.getInactivityProbe().toJava()));
}
String controllerNamedUuidString = SouthboundMapper.getRandomUuid();
UUID controllerNamedUuid = new UUID(controllerNamedUuidString);
transaction.add(op.insert(controller).withId(controllerNamedUuidString));
- Bridge bridge = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Bridge.class);
+ Bridge bridge = transaction.getTypedRowWrapper(Bridge.class);
bridge.setName(ovsdbBridge.getBridgeName().getValue());
bridge.setController(Collections.singleton(controllerNamedUuid));
LOG.trace("Added controller : {} for bridge : {}",
LOG.trace("Executed transaction: {}", transaction.build());
}
-
}