+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
package org.opendaylight.ovsdb.southbound.transactions.md;
import java.net.InetAddress;
import org.apache.commons.lang3.math.NumberUtils;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.ovsdb.lib.error.SchemaVersionMismatchException;
import org.opendaylight.ovsdb.lib.message.TableUpdates;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.southbound.OvsdbConnectionInstance;
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.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
private void updateBridge(ReadWriteTransaction transaction,
Bridge bridge) {
final InstanceIdentifier<Node> connectionIId = getOvsdbConnectionInstance().getInstanceIdentifier();
- Optional<Node> connection = readNode(transaction, connectionIId);
+ Optional<Node> connection = SouthboundUtil.readNode(transaction, connectionIId);
if (connection.isPresent()) {
LOG.debug("Connection {} is present",connection);
InstanceIdentifier<Node> bridgeIid, Bridge bridge) {
Preconditions.checkNotNull(bridgeIid);
Preconditions.checkNotNull(bridge);
- List<InstanceIdentifier<BridgeOtherConfigs>> result =
- new ArrayList<InstanceIdentifier<BridgeOtherConfigs>>();
+ List<InstanceIdentifier<BridgeOtherConfigs>> result = new ArrayList<>();
Bridge oldBridge = oldBridgeRows.get(bridge.getUuid());
InstanceIdentifier<Node> bridgeIid, Bridge bridge) {
Preconditions.checkNotNull(bridgeIid);
Preconditions.checkNotNull(bridge);
- List<InstanceIdentifier<BridgeExternalIds>> result =
- new ArrayList<InstanceIdentifier<BridgeExternalIds>>();
+ List<InstanceIdentifier<BridgeExternalIds>> result = new ArrayList<>();
Bridge oldBridge = oldBridgeRows.get(bridge.getUuid());
InstanceIdentifier<Node> bridgeIid, Bridge bridge) {
Preconditions.checkNotNull(bridgeIid);
Preconditions.checkNotNull(bridge);
- List<InstanceIdentifier<ProtocolEntry>> result =
- new ArrayList<InstanceIdentifier<ProtocolEntry>>();
+ List<InstanceIdentifier<ProtocolEntry>> result = new ArrayList<>();
Bridge oldBridge = oldBridgeRows.get(bridge.getUuid());
try {
}
}
} catch (SchemaVersionMismatchException e) {
- LOG.warn("protocol not supported by this version of ovsdb", e);
+ // We don't care about the exception stack trace here
+ LOG.warn("protocol not supported by this version of ovsdb: {}", e.getMessage());
}
return result;
}
- private Optional<Node> readNode(ReadWriteTransaction transaction,
- final InstanceIdentifier<Node> connectionIid) {
- Optional<Node> node = Optional.absent();
- try {
- node = transaction.read(LogicalDatastoreType.OPERATIONAL, connectionIid).checkedGet();
- } catch (final ReadFailedException e) {
- LOG.warn("Read Operational/DS for Node fail! {}", connectionIid, e);
- }
- return node;
- }
-
private Node buildConnectionNode(
Bridge bridge) {
//Update node with managed node reference
connectionNode.setNodeId(getOvsdbConnectionInstance().getNodeId());
OvsdbNodeAugmentationBuilder ovsdbConnectionAugmentationBuilder = new OvsdbNodeAugmentationBuilder();
- List<ManagedNodeEntry> managedBridges = new ArrayList<ManagedNodeEntry>();
+ List<ManagedNodeEntry> managedBridges = new ArrayList<>();
InstanceIdentifier<Node> bridgeIid = SouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(),
bridge);
ManagedNodeEntry managedBridge = new ManagedNodeEntryBuilder().setBridgeRef(
connectionNode.addAugmentation(OvsdbNodeAugmentation.class, ovsdbConnectionAugmentationBuilder.build());
- LOG.debug("Update node with bridge node ref {}",ovsdbConnectionAugmentationBuilder.toString());
+ LOG.debug("Update node with bridge node ref {}",
+ ovsdbConnectionAugmentationBuilder.getManagedNodeEntry().iterator().next());
return connectionNode.build();
}
bridgeNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, ovsdbBridgeAugmentationBuilder.build());
LOG.debug("Built with the intent to store bridge data {}",
- ovsdbBridgeAugmentationBuilder.toString());
+ ovsdbBridgeAugmentationBuilder.build());
return bridgeNodeBuilder.build();
}
.getOtherConfigColumn().getData();
if (otherConfigs != null && !otherConfigs.isEmpty()) {
Set<String> otherConfigKeys = otherConfigs.keySet();
- List<BridgeOtherConfigs> otherConfigList = new ArrayList<BridgeOtherConfigs>();
+ List<BridgeOtherConfigs> otherConfigList = new ArrayList<>();
String otherConfigValue;
for (String otherConfigKey : otherConfigKeys) {
otherConfigValue = otherConfigs.get(otherConfigKey);
.getData();
if (externalIds != null && !externalIds.isEmpty()) {
Set<String> externalIdKeys = externalIds.keySet();
- List<BridgeExternalIds> externalIdsList = new ArrayList<BridgeExternalIds>();
+ List<BridgeExternalIds> externalIdsList = new ArrayList<>();
String externalIdValue;
for (String externalIdKey : externalIdKeys) {
externalIdValue = externalIds.get(externalIdKey);