description "MAC address entry";
type yang:mac-address;
}
+ leaf mac-entry-uuid {
+ description "The unique identifier of the mac-entry";
+ type yang:uuid;
+ }
leaf logical-switch-ref {
description "The logical switch to which this mapping applies";
type hwvtep-logical-switch-ref;
HwvtepGlobalAugmentation hgUpdated = updated.getAugmentation(HwvtepGlobalAugmentation.class);
HwvtepGlobalAugmentation hgOriginal = original.getAugmentation(HwvtepGlobalAugmentation.class);
// Check if user has updated connection information
- if (hgUpdated != null && hgOriginal != null && hgUpdated.getConnectionInfo() != null) {
+ if (hgUpdated != null && hgOriginal != null && hgUpdated.getConnectionInfo() != null
+ && !hgUpdated.getConnectionInfo().equals(hgOriginal.getConnectionInfo())) {
OvsdbClient client = hcm.getClient(hgUpdated.getConnectionInfo());
if (client == null) {
try {
/*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others. All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute 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,
setTunnelKey(logicalSwitch, lswitch);
if (!operationalSwitchOptional.isPresent()) {
setName(logicalSwitch, lswitch, operationalSwitchOptional);
+ LOG.trace("execute: creating LogicalSwitch entry: {}", logicalSwitch);
transaction.add(op.insert(logicalSwitch));
+ transaction.add(op.comment("Logical Switch: Creating " + lswitch.getHwvtepNodeName().getValue()));
} else {
LogicalSwitches updatedLSwitch = operationalSwitchOptional.get();
String existingLogicalSwitchName = updatedLSwitch.getHwvtepNodeName().getValue();
// Name is immutable, and so we *can't* update it. So we use extraBridge for the schema stuff
LogicalSwitch extraLogicalSwitch = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), LogicalSwitch.class);
extraLogicalSwitch.setName("");
+ LOG.trace("execute: updating LogicalSwitch entry: {}", logicalSwitch);
transaction.add(op.update(logicalSwitch)
.where(extraLogicalSwitch.getNameColumn().getSchema().opEqual(existingLogicalSwitchName))
.build());
+ transaction.add(op.comment("Logical Switch: Updating " + existingLogicalSwitchName));
}
}
}
/*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others. All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute 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,
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundConstants;
+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.hardwarevtep.McastMacsLocal;
import com.google.common.base.Optional;
public class McastMacsLocalRemoveCommand extends AbstractTransactCommand {
- private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+ private static final Logger LOG = LoggerFactory.getLogger(McastMacsLocalRemoveCommand.class);
public McastMacsLocalRemoveCommand(HwvtepOperationalState state,
Collection<DataTreeModification<Node>> changes) {
getOperationalState().getLocalMcastMacs(instanceIdentifier, mac.getKey());
McastMacsLocal mcastMacsLocal = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
McastMacsLocal.class, null);
- if (operationalMacOptional.isPresent()) {
+ if (operationalMacOptional.isPresent() && operationalMacOptional.get().getMacEntryUuid() != null) {
//when mac entry is deleted, its referenced locator set and locators are deleted automatically.
//TODO: locator in config DS is not deleted
- String macString = null;
- if (mac.getMacEntryKey().equals(HwvtepSouthboundConstants.UNKNOWN_DST_MAC)) {
- macString = HwvtepSouthboundConstants.UNKNOWN_DST_STRING;
- } else {
- macString = mac.getMacEntryKey().getValue();
- }
- transaction.add(op.delete(mcastMacsLocal.getSchema())
- .where(mcastMacsLocal.getMacColumn().getSchema().opEqual(macString)).build());
- transaction.add(op.comment("Local McastMacLocal: Deleting " + mac.getMacEntryKey().getValue()));
+ UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+ transaction.add(op.delete(mcastMacsLocal.getSchema()).
+ where(mcastMacsLocal.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
+ transaction.add(op.comment("McastMacLocal: Deleting " + mac.getMacEntryKey().getValue()));
} else {
LOG.warn("Unable to delete localMcastMacs {} because it was not found in the operational store",
mac.getMacEntryKey().getValue());
/*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others. All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute 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,
import com.google.common.base.Optional;
public class McastMacsLocalUpdateCommand extends AbstractTransactCommand {
- private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+ private static final Logger LOG = LoggerFactory.getLogger(McastMacsLocalUpdateCommand.class);
public McastMacsLocalUpdateCommand(HwvtepOperationalState state,
Collection<DataTreeModification<Node>> changes) {
setLogicalSwitch(mcastMacsLocal, localMcastMac);
if (!operationalMacOptional.isPresent()) {
setMac(mcastMacsLocal, localMcastMac, operationalMacOptional);
+ LOG.trace("execute: create LocalMcastMac entry: {}", mcastMacsLocal);
transaction.add(op.insert(mcastMacsLocal));
+ transaction.add(op.comment("McastMacLocal: Creating " + localMcastMac.getMacEntryKey().getValue()));
} else {
LocalMcastMacs updatedMac = operationalMacOptional.get();
String existingMac = updatedMac.getMacEntryKey().getValue();
McastMacsLocal extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), McastMacsLocal.class);
- extraMac.setMac("");;
+ extraMac.setMac("");
+ LOG.trace("execute: update LocalMcastMac entry: {}", mcastMacsLocal);
transaction.add(op.update(mcastMacsLocal)
.where(extraMac.getMacColumn().getSchema().opEqual(existingMac))
.build());
+ transaction.add(op.comment("McastMacLocal: Updating " + localMcastMac.getMacEntryKey().getValue()));
}
}
}
/*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others. All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute 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,
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundConstants;
+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.hardwarevtep.McastMacsRemote;
import com.google.common.base.Optional;
public class McastMacsRemoteRemoveCommand extends AbstractTransactCommand {
- private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+ private static final Logger LOG = LoggerFactory.getLogger(McastMacsRemoteRemoveCommand.class);
public McastMacsRemoteRemoveCommand(HwvtepOperationalState state,
Collection<DataTreeModification<Node>> changes) {
getOperationalState().getRemoteMcastMacs(instanceIdentifier, mac.getKey());
McastMacsRemote mcastMacsRemote = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
McastMacsRemote.class, null);
- if (operationalMacOptional.isPresent()) {
+ if (operationalMacOptional.isPresent() && operationalMacOptional.get().getMacEntryUuid() != null) {
//when mac entry is deleted, its referenced locator set and locators are deleted automatically.
//TODO: locator in config DS is not deleted
- String macString = null;
- if (mac.getMacEntryKey().equals(HwvtepSouthboundConstants.UNKNOWN_DST_MAC)) {
- macString = HwvtepSouthboundConstants.UNKNOWN_DST_STRING;
- } else {
- macString = mac.getMacEntryKey().getValue();
- }
- transaction.add(op.delete(mcastMacsRemote.getSchema())
- .where(mcastMacsRemote.getMacColumn().getSchema().opEqual(macString)).build());
- transaction.add(op.comment("Remote McastMacRemote: Deleting " + mac.getMacEntryKey().getValue()));
+ UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+ transaction.add(op.delete(mcastMacsRemote.getSchema()).
+ where(mcastMacsRemote.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
+ transaction.add(op.comment("McastMacRemote: Deleting " + mac.getMacEntryKey().getValue()));
} else {
LOG.warn("Unable to delete remoteMcastMacs {} because it was not found in the operational store",
mac.getMacEntryKey().getValue());
/*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others. All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute 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,
import com.google.common.base.Optional;
public class McastMacsRemoteUpdateCommand extends AbstractTransactCommand {
- private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+ private static final Logger LOG = LoggerFactory.getLogger(McastMacsRemoteUpdateCommand.class);
public McastMacsRemoteUpdateCommand(HwvtepOperationalState state,
Collection<DataTreeModification<Node>> changes) {
setLogicalSwitch(mcastMacsRemote, mac);
if (!operationalMacOptional.isPresent()) {
setMac(mcastMacsRemote, mac, operationalMacOptional);
+ LOG.trace("execute: create RemoteMcastMac entry: {}", mcastMacsRemote);
transaction.add(op.insert(mcastMacsRemote));
+ transaction.add(op.comment("McastMacRemote: Creating " + mac.getMacEntryKey().getValue()));
} else {
RemoteMcastMacs updatedMac = operationalMacOptional.get();
String existingMac = updatedMac.getMacEntryKey().getValue();
McastMacsRemote extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), McastMacsRemote.class);
- extraMac.setMac("");;
+ extraMac.setMac("");
+ LOG.trace("execute: update RemoteMcastMac entry: {}", mcastMacsRemote);
transaction.add(op.update(mcastMacsRemote)
.where(extraMac.getMacColumn().getSchema().opEqual(existingMac))
.build());
+ transaction.add(op.comment("McastMacRemote: Updating " + mac.getMacEntryKey().getValue()));
}
}
}
/*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others. All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute 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,
//create a physical port
setName(physicalPort, port, operationalPhysicalPortOptional);
String portUuid = "PhysicalPort_" + HwvtepSouthboundMapper.getRandomUUID();
+ LOG.trace("execute: creating physical port: {}", physicalPort);
transaction.add(op.insert(physicalPort).withId(portUuid));
+ transaction.add(op.comment("Physical Port: Creating " + port.getHwvtepNodeName().getValue()));
//update physical switch table
PhysicalSwitch physicalSwitch = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), PhysicalSwitch.class);
physicalSwitch.setName(physicalSwitchBelong.getHwvtepNodeName().getValue());
physicalSwitch.setPorts(Sets.newHashSet(new UUID(portUuid)));
- LOG.info("execute: physical switch: {}", physicalSwitch);
+ LOG.trace("execute: mutating physical switch: {}", physicalSwitch);
transaction.add(op.mutate(physicalSwitch)
.addMutation(physicalSwitch.getPortsColumn().getSchema(), Mutator.INSERT,
physicalSwitch.getPortsColumn().getData())
.where(physicalSwitch.getNameColumn().getSchema().opEqual(physicalSwitch.getNameColumn().getData()))
.build());
+ transaction.add(op.comment("Physical Switch: Mutating " +
+ port.getHwvtepNodeName().getValue() + " " + portUuid));
} else {
//updated physical port only
HwvtepPhysicalPortAugmentation updatedPhysicalPort = operationalPhysicalPortOptional.get();
PhysicalPort extraPhyscialPort =
TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), PhysicalPort.class);
extraPhyscialPort.setName("");
+ LOG.trace("execute: updating physical port: {}", physicalPort);
transaction.add(op.update(physicalPort)
.where(extraPhyscialPort.getNameColumn().getSchema().opEqual(existingPhysicalPortName))
.build());
+ transaction.add(op.comment("Physical Port: Updating " + existingPhysicalPortName));
}
}
}
/*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others. All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute 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,
setDescription(physicalSwitch, physicalSwitchAugmentation);
setManagementIps(physicalSwitch, physicalSwitchAugmentation);
setTunnuleIps(physicalSwitch, physicalSwitchAugmentation);
- setTunnels(transaction, iid, physicalSwitch, physicalSwitchAugmentation);
+ setTunnels(transaction, iid, physicalSwitch, physicalSwitchAugmentation,
+ operationalPhysicalSwitchOptional.isPresent());
if (!operationalPhysicalSwitchOptional.isPresent()) {
//create a physical switch
setName(physicalSwitch, physicalSwitchAugmentation, operationalPhysicalSwitchOptional);
String pswitchUuid = "PhysicalSwitch_" + HwvtepSouthboundMapper.getRandomUUID();
transaction.add(op.insert(physicalSwitch).withId(pswitchUuid));
+ transaction.add(op.comment("Physical Switch: Creating " +
+ physicalSwitchAugmentation.getHwvtepNodeName().getValue()));
//update global table
Global global = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Global.class);
global.setSwitches(Sets.newHashSet(new UUID(pswitchUuid)));
- LOG.debug("execute: physical switch: {}", physicalSwitch);
+ LOG.trace("execute: create physical switch: {}", physicalSwitch);
transaction.add(op.mutate(global)
.addMutation(global.getSwitchesColumn().getSchema(), Mutator.INSERT,
global.getSwitchesColumn().getData()));
+ transaction.add(op.comment("Global: Mutating " +
+ physicalSwitchAugmentation.getHwvtepNodeName().getValue() + " " + pswitchUuid));
} else {
PhysicalSwitchAugmentation updatedPhysicalSwitch = operationalPhysicalSwitchOptional.get();
String existingPhysicalSwitchName = updatedPhysicalSwitch.getHwvtepNodeName().getValue();
+ /* In case TOR devices don't allow creation of PhysicalSwitch name might be null
+ * as user is only adding configurable parameters to MDSAL like BFD params
+ *
+ * TODO Note: Consider handling tunnel udpate/remove in separate command
+ */
+ if(existingPhysicalSwitchName == null) {
+ existingPhysicalSwitchName = operationalPhysicalSwitchOptional.get().getHwvtepNodeName().getValue();
+ }
// Name is immutable, and so we *can't* update it. So we use extraPhysicalSwitch for the schema stuff
PhysicalSwitch extraPhysicalSwitch = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), PhysicalSwitch.class);
extraPhysicalSwitch.setName("");
+ LOG.trace("execute: updating physical switch: {}", physicalSwitch);
transaction.add(op.update(physicalSwitch)
.where(extraPhysicalSwitch.getNameColumn().getSchema().opEqual(existingPhysicalSwitchName))
.build());
+ transaction.add(op.comment("Physical Switch: Updating " + existingPhysicalSwitchName));
}
}
@SuppressWarnings("unchecked")
private void setTunnels(TransactionBuilder transaction, InstanceIdentifier<Node> iid,
- PhysicalSwitch physicalSwitch, PhysicalSwitchAugmentation physicalSwitchAugmentation) {
+ PhysicalSwitch physicalSwitch, PhysicalSwitchAugmentation physicalSwitchAugmentation,
+ boolean pSwitchExists) {
//TODO: revisit this code for optimizations
//TODO: needs more testing
if(physicalSwitchAugmentation.getTunnels() != null) {
- Set<UUID> tunnels = Sets.newHashSet();
for(Tunnels tunnel: physicalSwitchAugmentation.getTunnels()) {
Optional<Tunnels> opTunnelOpt = getOperationalState().getTunnels(iid, tunnel.getKey());
Tunnel newTunnel = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Tunnel.class);
- String tunnelUuid = null;
- if(!opTunnelOpt.isPresent()) {
- tunnelUuid = "Tunnel_" + HwvtepSouthboundMapper.getRandomUUID();
- } else {
- tunnelUuid = opTunnelOpt.get().getTunnelUuid().getValue();
- }
+
UUID localUUID = getLocatorUUID(transaction,
(InstanceIdentifier<TerminationPoint>) tunnel.getLocalLocatorRef().getValue());
UUID remoteUUID = getLocatorUUID(transaction,
(InstanceIdentifier<TerminationPoint>) tunnel.getRemoteLocatorRef().getValue());
if(localUUID != null && remoteUUID != null) {
+ UUID uuid;
// local and remote must exist
newTunnel.setLocal(localUUID);
newTunnel.setRemote(remoteUUID);
setBfdParams(newTunnel, tunnel);
setBfdLocalConfigs(newTunnel, tunnel);
setBfdRemoteConfigs(newTunnel, tunnel);
- transaction.add(op.insert(newTunnel).withId(tunnelUuid));
- tunnels.add(new UUID(tunnelUuid));
+ if(!opTunnelOpt.isPresent()) {
+ String tunnelUuid = "Tunnel_" + HwvtepSouthboundMapper.getRandomUUID();
+ transaction.add(op.insert(newTunnel).withId(tunnelUuid));
+ transaction.add(op.comment("Tunnel: Creating " + tunnelUuid));
+ if(!pSwitchExists) {
+ //TODO: Figure out a way to handle this
+ LOG.warn("Tunnel configuration requires pre-existing physicalSwitch");
+ } else {
+ // TODO: Can we reuse physicalSwitch instead?
+ PhysicalSwitch pSwitch =
+ TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
+ PhysicalSwitch.class);
+ pSwitch.setTunnels(Sets.newHashSet(new UUID(tunnelUuid)));
+ pSwitch.setName(physicalSwitchAugmentation.getHwvtepNodeName().getValue());
+ transaction.add(op.mutate(pSwitch)
+ .addMutation(pSwitch.getTunnels().getSchema(), Mutator.INSERT,
+ pSwitch.getTunnels().getData())
+ .where(pSwitch.getNameColumn().getSchema().
+ opEqual(pSwitch.getNameColumn().getData()))
+ .build());
+ transaction.add(op.comment("PhysicalSwitch: Mutating " + tunnelUuid));
+ }
+ uuid = new UUID(tunnelUuid);
+ } else {
+ uuid = new UUID (opTunnelOpt.get().getTunnelUuid().getValue());
+ Tunnel extraTunnel =
+ TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Tunnel.class, null);
+ extraTunnel.getUuidColumn().setData(uuid);
+ transaction.add(op.update(newTunnel)
+ .where(extraTunnel.getUuidColumn().getSchema().opEqual(uuid))
+ .build());
+ transaction.add(op.comment("Tunnel: Updating " + uuid));
+ }
}
}
- physicalSwitch.setTunnels(tunnels);
}
}
/*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others. All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute 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,
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+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.hardwarevtep.UcastMacsLocal;
import com.google.common.base.Optional;
public class UcastMacsLocalRemoveCommand extends AbstractTransactCommand {
- private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+ private static final Logger LOG = LoggerFactory.getLogger(UcastMacsLocalRemoveCommand.class);
public UcastMacsLocalRemoveCommand(HwvtepOperationalState state,
Collection<DataTreeModification<Node>> changes) {
LOG.debug("Removing remoteUcastMacs, mac address: {}", mac.getMacEntryKey().getValue());
Optional<LocalUcastMacs> operationalMacOptional =
getOperationalState().getLocalUcastMacs(instanceIdentifier, mac.getKey());
- UcastMacsLocal mcastMacsLocal = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
+ UcastMacsLocal ucastMacsLocal = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
UcastMacsLocal.class, null);
- if (operationalMacOptional.isPresent()) {
+ if (operationalMacOptional.isPresent() && operationalMacOptional.get().getMacEntryUuid() != null) {
//when mac entry is deleted, its referenced locators are deleted automatically.
//locators in config DS is not deleted and user need to be removed explicitly by user.
- transaction.add(op.delete(mcastMacsLocal.getSchema())
- .where(mcastMacsLocal.getMacColumn().getSchema().opEqual(mac.getMacEntryKey().getValue())).build());
- transaction.add(op.comment("Local UcastMacLocal: Deleting " + mac.getMacEntryKey().getValue()));
+ UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+ transaction.add(op.delete(ucastMacsLocal.getSchema()).
+ where(ucastMacsLocal.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
+ transaction.add(op.comment("UcastMacLocal: Deleting " + mac.getMacEntryKey().getValue()));
} else {
LOG.warn("Unable to delete remoteUcastMacs {} because it was not found in the operational store",
mac.getMacEntryKey().getValue());
/*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others. All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute 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,
import com.google.common.base.Optional;
public class UcastMacsLocalUpdateCommand extends AbstractTransactCommand {
- private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+ private static final Logger LOG = LoggerFactory.getLogger(UcastMacsLocalUpdateCommand.class);
public UcastMacsLocalUpdateCommand(HwvtepOperationalState state,
Collection<DataTreeModification<Node>> changes) {
setLogicalSwitch(ucastMacsLocal, localUcastMac);
if (!operationalMacOptional.isPresent()) {
setMac(ucastMacsLocal, localUcastMac, operationalMacOptional);
+ LOG.trace("execute: creating LocalUcastMac entry: {}", ucastMacsLocal);
transaction.add(op.insert(ucastMacsLocal));
+ transaction.add(op.comment("UcastMacLocal: Creating " + localUcastMac.getMacEntryKey().getValue()));
} else {
LocalUcastMacs updatedMac = operationalMacOptional.get();
String existingMac = updatedMac.getMacEntryKey().getValue();
UcastMacsLocal extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), UcastMacsLocal.class);
- extraMac.setMac("");;
+ extraMac.setMac("");
+ LOG.trace("execute: updating LocalUcastMac entry: {}", ucastMacsLocal);
transaction.add(op.update(ucastMacsLocal)
.where(extraMac.getMacColumn().getSchema().opEqual(existingMac))
.build());
+ transaction.add(op.comment("UcastMacLocal: Updating " + localUcastMac.getMacEntryKey().getValue()));
}
}
}
/*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others. All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute 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,
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+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.hardwarevtep.UcastMacsRemote;
import com.google.common.base.Optional;
public class UcastMacsRemoteRemoveCommand extends AbstractTransactCommand {
- private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+ private static final Logger LOG = LoggerFactory.getLogger(UcastMacsRemoteRemoveCommand.class);
public UcastMacsRemoteRemoveCommand(HwvtepOperationalState state,
Collection<DataTreeModification<Node>> changes) {
LOG.debug("Removing remoteUcastMacs, mac address: {}", mac.getMacEntryKey().getValue());
Optional<RemoteUcastMacs> operationalMacOptional =
getOperationalState().getRemoteUcastMacs(instanceIdentifier, mac.getKey());
- UcastMacsRemote mcastMacsRemote = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
+ UcastMacsRemote ucastMacsRemote = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
UcastMacsRemote.class, null);
- if (operationalMacOptional.isPresent()) {
+ if (operationalMacOptional.isPresent() && operationalMacOptional.get().getMacEntryUuid() != null) {
//when mac entry is deleted, its referenced locators are deleted automatically.
//locators in config DS is not deleted and need to be removed explicitly by user.
- transaction.add(op.delete(mcastMacsRemote.getSchema())
- .where(mcastMacsRemote.getMacColumn().getSchema().opEqual(mac.getMacEntryKey().getValue())).build());
- transaction.add(op.comment("Remote UcastMacRemote: Deleting " + mac.getMacEntryKey().getValue()));
+ UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+ transaction.add(op.delete(ucastMacsRemote.getSchema()).
+ where(ucastMacsRemote.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
+ transaction.add(op.comment("UcastMacRemote: Deleting " + mac.getMacEntryKey().getValue()));
} else {
LOG.warn("Unable to delete remoteUcastMacs {} because it was not found in the operational store",
mac.getMacEntryKey().getValue());
/*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others. All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute 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,
import org.opendaylight.ovsdb.schema.hardwarevtep.UcastMacsRemote;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitchesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacs;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import com.google.common.base.Optional;
public class UcastMacsRemoteUpdateCommand extends AbstractTransactCommand {
- private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+ private static final Logger LOG = LoggerFactory.getLogger(UcastMacsRemoteUpdateCommand.class);
public UcastMacsRemoteUpdateCommand(HwvtepOperationalState state,
Collection<DataTreeModification<Node>> changes) {
setLogicalSwitch(ucastMacsRemote, remoteUcastMac);
if (!operationalMacOptional.isPresent()) {
setMac(ucastMacsRemote, remoteUcastMac, operationalMacOptional);
+ LOG.trace("execute: creating RemotUcastMac entry: {}", ucastMacsRemote);
transaction.add(op.insert(ucastMacsRemote));
+ transaction.add(op.comment("UcastMacRemote: Creating " + remoteUcastMac.getMacEntryKey().getValue()));
} else {
RemoteUcastMacs updatedMac = operationalMacOptional.get();
String existingMac = updatedMac.getMacEntryKey().getValue();
UcastMacsRemote extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), UcastMacsRemote.class);
- extraMac.setMac("");;
+ extraMac.setMac("");
+ LOG.trace("execute: updating RemotUcastMac entry: {}", ucastMacsRemote);
transaction.add(op.update(ucastMacsRemote)
.where(extraMac.getMacColumn().getSchema().opEqual(existingMac))
.build());
+ transaction.add(op.comment("UcastMacRemote: Updating " + remoteUcastMac.getMacEntryKey().getValue()));
}
}
}
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015, 2016 Ericsson India Global Services Pvt Ltd. 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,
import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocatorSet;
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.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef;
} else {
mMacLocalBuilder.setMacEntryKey(new MacAddress(mMacLocal.getMac()));
}
+ mMacLocalBuilder.setMacEntryUuid(new Uuid(mMacLocal.getUuid().toString()));
setIpAddress(mMacLocalBuilder, mMacLocal);
setLocatorSet(mMacLocalBuilder, mMacLocal);
setLogicalSwitch(mMacLocalBuilder, mMacLocal);
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015, 2016 Ericsson India Global Services Pvt Ltd. 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,
import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocatorSet;
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.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef;
} else {
mMacRemoteBuilder.setMacEntryKey(new MacAddress(mMacRemote.getMac()));
}
+ mMacRemoteBuilder.setMacEntryUuid(new Uuid(mMacRemote.getUuid().toString()));
setIpAddress(mMacRemoteBuilder, mMacRemote);
setLocatorSet(mMacRemoteBuilder, mMacRemote);
setLogicalSwitch(mMacRemoteBuilder, mMacRemote);
HwvtepSouthboundMapper.createInstanceIdentifier(node.getNodeId()), pLoc);
tBuilder.setLocalLocatorRef(new HwvtepPhysicalLocatorRef(tpPath));
}
-
+ tBuilder.setTunnelUuid(new Uuid(uuid.toString()));
setBfdLocalConfigs(tBuilder, tunnel);
setBfdRemoteConfigs(tBuilder, tunnel);
setBfdParams(tBuilder, tunnel);
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015, 2016 Ericsson India Global Services Pvt Ltd. 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,
package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
import com.google.common.base.Optional;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
import org.opendaylight.ovsdb.schema.hardwarevtep.UcastMacsLocal;
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.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef;
ucmlBuilder.setIpaddr(new IpAddress(ucml.getIpAddr().toCharArray()));
}
ucmlBuilder.setMacEntryKey(new MacAddress(ucml.getMac()));
+ ucmlBuilder.setMacEntryUuid(new Uuid(ucml.getUuid().toString()));
if (ucml.getLocatorColumn() != null && ucml.getLocatorColumn().getData() != null) {
UUID plocUUID = ucml.getLocatorColumn().getData();
PhysicalLocator physicalLocator = updatedPLocRows.get(plocUUID);
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015, 2016 Ericsson India Global Services Pvt Ltd. 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,
import org.opendaylight.ovsdb.schema.hardwarevtep.UcastMacsRemote;
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.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef;
List<RemoteUcastMacs> remoteUMacs = new ArrayList<>();
RemoteUcastMacsBuilder rumBuilder = new RemoteUcastMacsBuilder();
rumBuilder.setMacEntryKey(new MacAddress(uMacRemote.getMac()));
+ rumBuilder.setMacEntryUuid(new Uuid(uMacRemote.getUuid().toString()));
if (uMacRemote.getIpAddr() != null && !uMacRemote.getIpAddr().isEmpty()) {
rumBuilder.setIpaddr(new IpAddress(uMacRemote.getIpAddr().toCharArray()));
}
-->
<snapshot>
<required-capabilities>
- <capability>urn:opendaylight:params:xml:ns:yang:hwgw?module=hwgw&revision=2015-12-27</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:netvirt:hwgw?module=hwgw&revision=2015-12-27</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability>
</required-capabilities>
<configuration>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
<module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:hwgw">prefix:hwgw</type>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:netvirt:hwgw">prefix:hwgw</type>
<name>hwgw-default</name>
<broker>
<type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
+Copyright (c) 2016 Red Hat, 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
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-parent</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>neutron</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <dependencies>
+ <!-- Testing Dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+Copyright (c) 2016 Red Hat, 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
+-->
+<snapshot>
+ <required-capabilities>
+ <capability>urn:opendaylight:params:xml:ns:yang:netvirt:neutron?module=neutron&revision=2016-03-08</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability>
+ </required-capabilities>
+ <configuration>
+
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:netvirt:neutron">prefix:neutron</type>
+ <name>neutron-default</name>
+ <broker>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
+ <name>binding-osgi-broker</name>
+ </broker>
+ </module>
+ </modules>
+ </data>
+ </configuration>
+</snapshot>
--- /dev/null
+/*
+ * Copyright (c) 2016 Red Hat, 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.netvirt.renderers.neutron;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NeutronProvider implements BindingAwareProvider, AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(NeutronProvider.class);
+
+ @Override
+ public void onSessionInitiated(ProviderContext session) {
+ LOG.info("NeutronProvider Session Initiated");
+ }
+
+ @Override
+ public void close() throws Exception {
+ LOG.info("NeutronProvider Closed");
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Red Hat, 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308;
+
+import org.opendaylight.ovsdb.netvirt.renderers.neutron.NeutronProvider;
+
+public class NeutronModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308.AbstractNeutronModule {
+ public NeutronModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public NeutronModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308.NeutronModule oldModule, java.lang.AutoCloseable oldInstance) {
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ public void customValidation() {
+ // add custom validation form module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ NeutronProvider provider = new NeutronProvider();
+ getBrokerDependency().registerProvider(provider);
+ return provider;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Red Hat, 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
+ */
+/*
+* Generated file
+*
+* Generated from: yang module name: neutron yang module local name: neutron
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308;
+public class NeutronModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308.AbstractNeutronModuleFactory {
+
+}
--- /dev/null
+module neutron {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:netvirt:neutron";
+ prefix "neutron";
+
+ import config { prefix config; revision-date 2013-04-05; }
+ import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
+
+ description
+ "Service definition for NetVirt Neutron renderer";
+
+ revision "2016-03-08" {
+ description
+ "Initial revision";
+ }
+
+ identity neutron {
+ base config:module-type;
+ config:java-name-prefix Neutron;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case neutron {
+ when "/config:modules/config:module/config:type = 'neutron'";
+ container broker {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity md-sal-binding:binding-broker-osgi-registry;
+ }
+ }
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Red Hat, 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.netvirt.renderers.neutron;
+
+import org.junit.Test;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+
+import static org.mockito.Mockito.mock;
+
+public class NeutronProviderTest {
+ @Test
+ public void testOnSessionInitiated() {
+ NeutronProvider provider = new NeutronProvider();
+
+ // ensure no exceptions
+ // currently this method is empty
+ provider.onSessionInitiated(mock(BindingAwareBroker.ProviderContext.class));
+ }
+
+ @Test
+ public void testClose() throws Exception {
+ NeutronProvider provider = new NeutronProvider();
+
+ // ensure no exceptions
+ // currently this method is empty
+ provider.close();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Red Hat, 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308;
+
+import org.junit.Test;
+
+public class NeutronModuleFactoryTest {
+ @Test
+ public void testFactoryConstructor() {
+ // ensure no exceptions on construction
+ new NeutronModuleFactory();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Red Hat, 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308;
+
+import org.junit.Test;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.JmxAttribute;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.ovsdb.netvirt.renderers.neutron.NeutronProvider;
+
+import javax.management.ObjectName;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class NeutronModuleTest {
+ @Test
+ public void testCustomValidation() {
+ NeutronModule module = new NeutronModule(mock(ModuleIdentifier.class), mock(DependencyResolver.class));
+
+ // ensure no exceptions on validation
+ // currently this method is empty
+ module.customValidation();
+ }
+
+ @Test
+ public void testCreateInstance() throws Exception {
+ // configure mocks
+ DependencyResolver dependencyResolver = mock(DependencyResolver.class);
+ BindingAwareBroker broker = mock(BindingAwareBroker.class);
+ when(dependencyResolver.resolveInstance(eq(BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class))).thenReturn(broker);
+
+ // create instance of module with injected mocks
+ NeutronModule module = new NeutronModule(mock(ModuleIdentifier.class), dependencyResolver);
+
+ // getInstance calls resolveInstance to get the broker dependency and then calls createInstance
+ AutoCloseable closeable = module.getInstance();
+
+ // verify that the module registered the returned provider with the broker
+ verify(broker).registerProvider((NeutronProvider)closeable);
+
+ // ensure no exceptions on close
+ closeable.close();
+ }
+}
</prerequisites>
<modules>
<module>hwgw</module>
+ <module>neutron</module>
</modules>
<!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
<build>
return false;
}
+ public static boolean isMasterElected(){
+ if (entityOwnershipService != null) {
+ Optional<EntityOwnershipState> state = entityOwnershipService.getOwnershipState(ownerInstanceEntity);
+ return state.isPresent() && state.get().hasOwner();
+ }
+ return false;
+ }
+
@Override
public void close() throws Exception {
LOG.info("NetvirtProvider closed");
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.ovsdb.openstack.netvirt.ClusterAwareMdsalUtils;
import org.opendaylight.ovsdb.openstack.netvirt.ConfigInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.NetvirtProvider;
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbInventoryService;
import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbInventoryListener;
public void setDependencies(Object impl) {}
private void initializeNetvirtTopology() {
+ while(!NetvirtProvider.isMasterElected()){
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ LOG.warn("Netvirt thread waiting on Netvirt Ownership Election is interrupted");
+ }
+ }
final TopologyId topologyId = new TopologyId(new Uri(Constants.NETVIRT_TOPOLOGY_ID));
InstanceIdentifier<Topology> path =
InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(topologyId));
}
}
+ list interface-bfd {
+ description "BFD configuration for a particular interface.
+ BFD, defined in RFC 5880 and RFC 5881, allows point-to-point
+ detection of connectivity failures by occasional transmission of
+ BFD control messages.
+
+ bfd : enable: optional string, either true or false
+ True to enable BFD on this Interface. If not specified, BFD
+ will be disabled by default.
+
+ bfd : min_rx: optional string
+ containing an integer, at least 1.
+ The shortest interval, in milliseconds, at which this BFD session
+ offers to receive BFD control messages. The remote endpoint may
+ choose to send messages at a slower rate. Defaults to 1000.
+
+ bfd : min_tx: optional string
+ containing an integer, at least 1.
+ The shortest interval, in milliseconds, at which this BFD session is
+ willing to transmit BFD control messages. Messages will actually be
+ transmitted at a slower rate if the remote endpoint is not willing to
+ receive as quickly as specified. Defaults to 100.
+
+ bfd : decay_min_rx: optional string
+ containing an integer
+ An alternate receive interval, in milliseconds, that must be greater
+ than or equal to bfd:min_rx. The implementation switches from
+ bfd:min_rx to bfd:decay_min_rx when there is no obvious incoming
+ data traffic at the interface, to reduce the CPU and bandwidth cost
+ of monitoring an idle interface. This feature may be disabled by
+ setting a value of 0. This feature is reset whenever bfd:decay_min_rx
+ bfd:min_rx changes.
+
+ bfd : forwarding_if_rx: optional string, either true or false
+ When true, traffic received on the Interface is used to
+ indicate the capability of packet I/O. BFD control packets are
+ still transmitted and received. At least one BFD control
+ packet must be received every 100 * bfd:min_rx amount of time.
+ Otherwise, even if traffic are received, the bfd-status:forwarding
+ will be false.
+
+ bfd : cpath_down: optional string, either true or false
+ Set to true to notify the remote endpoint that traffic should not be
+ forwarded to this system for some reason other than a connectivity
+ failure on the interface being monitored. The typical underlying
+ reason is concatenated path down, that is, that connectivity
+ beyond the local system is down. Defaults to false.
+
+ bfd : cpath_down: optional string, either true or false
+ Set to true to notify the remote endpoint that traffic should not be
+ forwarded to this system for some reason other than a connectivity
+ failure on the interface being monitored. The typical underlying
+ reason is concatenated path down, that is, that connectivity
+ beyond the local system is down. Defaults to false.
+
+ bfd : check_tnl_key: optional string, either true or false
+ Set to true to make BFD accept only control messages with a tunnel
+ key of zero. By default, BFD accepts control messages with any
+ tunnel key.
+
+ bfd : bfd_local_dst_mac: optional string, mac address
+ Set to an Ethernet address in the form xx:xx:xx:xx:xx:xx
+ to set the MAC used as destination for transmitted BFD packets. The
+ default is 00:23:20:00:00:01
+
+ bfd : bfd_remote_dst_mac: optional string, mac address
+ Set to an Ethernet address in the form xx:xx:xx:xx:xx:xx
+ to set the MAC used for checking the destination of received BFD packets.
+ Packets with different destination MAC will not be considered as BFD packets.
+ If not specified the destination MAC address of received BFD packets
+ are not checked.
+
+ bfd : bfd_src_ip: optional string, ip address
+ Set to an IPv4 address to set the IP address used as source
+ for transmitted BFD packets. The default is 169.254.1.1
+
+ bfd : bfd_dst_ip: optional string, ip address
+ Set to an IPv4 address to set the IP address used as destination
+ for transmitted BFD packets. The default is 169.254.1.0";
+
+ key "bfd-key";
+ leaf bfd-key {
+ description "bfd name/key";
+ type string;
+ }
+ leaf bfd-value {
+ description "bfd value";
+ type string;
+ }
+ }
+
+ list interface-bfd-status {
+ description "BFD status for a particular interface.
+ The switch sets key-value pairs in the bfd_status column to
+ report the status of BFD on this interface. When BFD is not
+ enabled, with bfd:enable, the switch clears all key-value
+ pairs from bfd_status.
+
+ bfd_status : state: optional string, one of [admin_down, down, init, up]
+ Reports the state of the BFD session. The BFD session is fully
+ healthy and negotiated if UP.
+
+ bfd_status : forwarding: optional string, true or false
+ Reports whether the BFD session believes this Interface
+ may be used to forward traffic. Typically this means
+ the local session is signaling UP, and the remote
+ system isn't signaling a problem such as concatenated path down.
+
+ bfd_status : diagnostic: optional string
+ A diagnostic code specifying the local system's reason for the
+ last change in session state. The error messages are defined in
+ section 4.1 of [RFC 5880].
+
+ bfd_status : remote_state: optional string, one of [admin_down, down, init, up]
+ Reports the state of the remote endpoint's BFD session.
+
+ bfd_status : remote_diagnostic: optional string
+ A diagnostic code specifying the remote system's reason for the
+ last change in session state. The error messages are defined in
+ section 4.1 of [RFC 5880].
+
+ bfd_status : flap_count: optional string,
+ containing an integer, minimum 0
+ Counts the number of bfd_status:forwarding flaps since start.
+ A flap is considered as a change of the bfd_status:forwarding value.";
+
+ key "bfd-status-key";
+ leaf bfd-status-key {
+ description "bfd-status name/key";
+ type string;
+ }
+ leaf bfd-status-value {
+ description "bfd-status value";
+ type string;
+ }
+ }
+
leaf qos {
description "The unique identifier of the QoS entry for this port.";
type yang:uuid;
<feature version='${project.version}'>odl-ovsdb-southbound-api</feature>
<bundle>mvn:org.opendaylight.ovsdb/southbound-impl/{{VERSION}}</bundle>
<bundle>mvn:org.opendaylight.ovsdb/library/{{VERSION}}</bundle>
+ <bundle>mvn:org.opendaylight.ovsdb/utils.yang-utils/{{VERSION}}</bundle>
<bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/{{VERSION}}</bundle>
<bundle>mvn:com.fasterxml.jackson.core/jackson-core/{{VERSION}}</bundle>
<bundle>mvn:com.fasterxml.jackson.core/jackson-databind/{{VERSION}}</bundle>
<artifactId>schema.openvswitch</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>utils.yang-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015, 2016 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,
import org.opendaylight.ovsdb.southbound.ovsdb.transact.TransactInvokerImpl;
import org.opendaylight.ovsdb.southbound.ovsdb.transact.TransactUtils;
import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvoker;
+import org.opendaylight.ovsdb.utils.yang.YangUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchExternalIds;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ListenableFuture;
// OpenVSwitchPart
OpenVSwitch ovs = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), OpenVSwitch.class);
- Map<String, String> externalIdsMap = new HashMap<>();
List<OpenvswitchExternalIds> externalIds = this.initialCreateData.getOpenvswitchExternalIds();
- if (externalIds != null) {
- for (OpenvswitchExternalIds externalId : externalIds) {
- externalIdsMap.put(externalId.getExternalIdKey(), externalId.getExternalIdValue());
- }
- }
-
stampInstanceIdentifier(transaction,this.instanceIdentifier.firstIdentifierOf(Node.class));
try {
- ovs.setExternalIds(ImmutableMap.copyOf(externalIdsMap));
+ ovs.setExternalIds(
+ YangUtils.convertYangKeyValueListToMap(externalIds, OpenvswitchExternalIds::getExternalIdKey,
+ OpenvswitchExternalIds::getExternalIdValue));
Mutate<GenericTableSchema> mutate = op.mutate(ovs)
.addMutation(ovs.getExternalIdsColumn().getSchema(),
Mutator.INSERT,
List<OpenvswitchOtherConfigs> otherConfigs = this.initialCreateData.getOpenvswitchOtherConfigs();
if (otherConfigs != null) {
- Map<String, String> otherConfigsMap = new HashMap<>();
- for (OpenvswitchOtherConfigs otherConfig : otherConfigs) {
- otherConfigsMap.put(otherConfig.getOtherConfigKey(), otherConfig.getOtherConfigValue());
- }
try {
- ovs.setOtherConfig(ImmutableMap.copyOf(otherConfigsMap));
+ ovs.setOtherConfig(YangUtils.convertYangKeyValueListToMap(otherConfigs,
+ OpenvswitchOtherConfigs::getOtherConfigKey,
+ OpenvswitchOtherConfigs::getOtherConfigValue));
transaction.add(op.mutate(ovs).addMutation(ovs.getOtherConfigColumn().getSchema(),
Mutator.INSERT,
ovs.getOtherConfigColumn().getData()));
/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015, 2016 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,
import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import javax.annotation.Nonnull;
+
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.lib.operations.Insert;
import org.opendaylight.ovsdb.southbound.SouthboundConstants;
import org.opendaylight.ovsdb.southbound.SouthboundMapper;
import org.opendaylight.ovsdb.southbound.SouthboundUtil;
+import org.opendaylight.ovsdb.utils.yang.YangUtils;
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.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeExternalIds;
import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
public class BridgeUpdateCommand extends AbstractTransactCommand {
Map<String, String> externalIdMap = new HashMap<>();
externalIdMap.put(SouthboundConstants.IID_EXTERNAL_ID_KEY, SouthboundUtil.serializeInstanceIdentifier(iid));
// Set user provided external ids
- List<BridgeExternalIds> bridgeExternalId = ovsdbManagedNode.getBridgeExternalIds();
- if (bridgeExternalId != null) {
- for (BridgeExternalIds externalId : bridgeExternalId) {
- externalIdMap.put(externalId.getBridgeExternalIdKey(), externalId.getBridgeExternalIdValue());
- }
- }
try {
- bridge.setExternalIds(ImmutableMap.copyOf(externalIdMap));
+ YangUtils.copyYangKeyValueListToMap(externalIdMap, ovsdbManagedNode.getBridgeExternalIds(),
+ BridgeExternalIds::getBridgeExternalIdKey, BridgeExternalIds::getBridgeExternalIdValue);
} catch (NullPointerException e) {
LOG.warn("Incomplete bridge external Id", e);
}
+ bridge.setExternalIds(externalIdMap);
}
- private void setOpenDaylightOtherConfig(Bridge bridge, OvsdbBridgeAugmentation ovsdbManagedNode) {
- List<BridgeOtherConfigs> bridgeOtherConfig = ovsdbManagedNode.getBridgeOtherConfigs();
- if (bridgeOtherConfig != null) {
- Map<String, String> otherConfigMap = new HashMap<>();
- for (BridgeOtherConfigs otherConf : bridgeOtherConfig) {
- otherConfigMap.put(otherConf.getBridgeOtherConfigKey(), otherConf.getBridgeOtherConfigValue());
- }
- try {
- bridge.setOtherConfig(ImmutableMap.copyOf(otherConfigMap));
- } catch (NullPointerException e) {
- LOG.warn("Incomplete bridge other config", e);
- }
+ private void setOpenDaylightOtherConfig(@Nonnull Bridge bridge, @Nonnull OvsdbBridgeAugmentation ovsdbManagedNode) {
+ try {
+ bridge.setOtherConfig(YangUtils.convertYangKeyValueListToMap(ovsdbManagedNode.getBridgeOtherConfigs(),
+ BridgeOtherConfigs::getBridgeOtherConfigKey, BridgeOtherConfigs::getBridgeOtherConfigValue));
+ } catch (NullPointerException e) {
+ LOG.warn("Incomplete bridge other config", e);
}
}
/*
- * Copyright (c) 2015 Intel Corporation and others. All rights reserved.
+ * Copyright (c) 2015, 2016 Intel Corporation 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,
import static org.opendaylight.ovsdb.lib.operations.Operations.op;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
+import org.opendaylight.ovsdb.utils.yang.YangUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchExternalIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.ImmutableMap;
-
public class OvsdbNodeUpdateCommand implements TransactCommand {
private AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes;
private static final Logger LOG = LoggerFactory.getLogger(OvsdbNodeUpdateCommand.class);
// OpenVSwitchPart
OpenVSwitch ovs = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), OpenVSwitch.class);
- Map<String, String> externalIdsMap = new HashMap<>();
-
- List<OpenvswitchExternalIds> externalIds = ovsdbNode.getOpenvswitchExternalIds();
-
- if (externalIds != null) {
- for (OpenvswitchExternalIds externalId : externalIds) {
- externalIdsMap.put(externalId.getExternalIdKey(), externalId.getExternalIdValue());
- }
- }
stampInstanceIdentifier(transaction,ovsdbNodeEntry.getKey().firstIdentifierOf(Node.class));
try {
- ovs.setExternalIds(ImmutableMap.copyOf(externalIdsMap));
+ ovs.setExternalIds(YangUtils.convertYangKeyValueListToMap(ovsdbNode.getOpenvswitchExternalIds(),
+ OpenvswitchExternalIds::getExternalIdKey, OpenvswitchExternalIds::getExternalIdValue));
Mutate<GenericTableSchema> mutate = op.mutate(ovs)
.addMutation(ovs.getExternalIdsColumn().getSchema(),
Mutator.INSERT,
List<OpenvswitchOtherConfigs> otherConfigs = ovsdbNode.getOpenvswitchOtherConfigs();
if (otherConfigs != null) {
- Map<String, String> otherConfigsMap = new HashMap<>();
- for (OpenvswitchOtherConfigs otherConfig : otherConfigs) {
- otherConfigsMap.put(otherConfig.getOtherConfigKey(), otherConfig.getOtherConfigValue());
- }
try {
- ovs.setOtherConfig(ImmutableMap.copyOf(otherConfigsMap));
+ ovs.setOtherConfig(YangUtils.convertYangKeyValueListToMap(otherConfigs,
+ OpenvswitchOtherConfigs::getOtherConfigKey, OpenvswitchOtherConfigs::getOtherConfigValue));
transaction.add(op.mutate(ovs).addMutation(ovs.getOtherConfigColumn().getSchema(),
Mutator.INSERT,
ovs.getOtherConfigColumn().getData()));
import static org.opendaylight.ovsdb.lib.operations.Operations.op;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.ovsdb.lib.notation.Condition;
-import org.opendaylight.ovsdb.lib.notation.Mutator;
import org.opendaylight.ovsdb.lib.notation.UUID;
-import org.opendaylight.ovsdb.lib.operations.Mutate;
import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
-import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
-import org.opendaylight.ovsdb.schema.openvswitch.Port;
import org.opendaylight.ovsdb.schema.openvswitch.Qos;
import org.opendaylight.ovsdb.southbound.SouthboundConstants;
import org.opendaylight.ovsdb.southbound.SouthboundMapper;
+import org.opendaylight.ovsdb.utils.yang.YangUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.QosEntries;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.qos.entries.QosExternalIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.qos.entries.QosOtherConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.ImmutableMap;
-
public class QosUpdateCommand extends AbstractTransactCommand {
private static final Logger LOG = LoggerFactory.getLogger(QosUpdateCommand.class);
}
qos.setQueues(newQueueList);
- List<QosExternalIds> externalIds = qosEntry.getQosExternalIds();
Map<String, String> externalIdsMap = new HashMap<>();
- if (externalIds != null) {
- for (QosExternalIds externalId : externalIds) {
- externalIdsMap.put(externalId.getQosExternalIdKey(), externalId.getQosExternalIdValue());
- }
- }
- externalIdsMap.put(SouthboundConstants.QOS_ID_EXTERNAL_ID_KEY, qosEntry.getQosId().getValue());
try {
- qos.setExternalIds(ImmutableMap.copyOf(externalIdsMap));
+ YangUtils.copyYangKeyValueListToMap(externalIdsMap, qosEntry.getQosExternalIds(),
+ QosExternalIds::getQosExternalIdKey, QosExternalIds::getQosExternalIdValue);
} catch (NullPointerException e) {
LOG.warn("Incomplete Qos external IDs", e);
}
+ externalIdsMap.put(SouthboundConstants.QOS_ID_EXTERNAL_ID_KEY, qosEntry.getQosId().getValue());
+ qos.setExternalIds(externalIdsMap);
- List<QosOtherConfig> otherConfigs = qosEntry.getQosOtherConfig();
- if (otherConfigs != null) {
- Map<String, String> otherConfigsMap = new HashMap<>();
- for (QosOtherConfig otherConfig : otherConfigs) {
- otherConfigsMap.put(otherConfig.getOtherConfigKey(), otherConfig.getOtherConfigValue());
- }
- try {
- qos.setOtherConfig(ImmutableMap.copyOf(otherConfigsMap));
- } catch (NullPointerException e) {
- LOG.warn("Incomplete Qos other_config", e);
- }
+ try {
+ qos.setOtherConfig(YangUtils.convertYangKeyValueListToMap(qosEntry.getQosOtherConfig(),
+ QosOtherConfig::getOtherConfigKey, QosOtherConfig::getOtherConfigValue));
+ } catch (NullPointerException e) {
+ LOG.warn("Incomplete Qos other_config", e);
}
if (uuid == null) {
transaction.add(op.insert(qos)).build();
import java.util.Set;
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.Mutate;
import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
-import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
-import org.opendaylight.ovsdb.schema.openvswitch.Qos;
import org.opendaylight.ovsdb.schema.openvswitch.Queue;
import org.opendaylight.ovsdb.southbound.SouthboundConstants;
-import org.opendaylight.ovsdb.southbound.SouthboundMapper;
+import org.opendaylight.ovsdb.utils.yang.YangUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.QosEntries;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.Queues;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.queues.QueuesExternalIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.queues.QueuesOtherConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.ImmutableMap;
-
public class QueueUpdateCommand extends AbstractTransactCommand {
private static final Logger LOG = LoggerFactory.getLogger(QueueUpdateCommand.class);
uuid = new UUID(queueUuid.getValue());
}
- List<QueuesExternalIds> externalIds = queueEntry.getQueuesExternalIds();
Map<String, String> externalIdsMap = new HashMap<>();
- if (externalIds != null) {
- for (QueuesExternalIds externalId : externalIds) {
- externalIdsMap.put(externalId.getQueuesExternalIdKey(), externalId.getQueuesExternalIdValue());
- }
- }
- externalIdsMap.put(SouthboundConstants.QUEUE_ID_EXTERNAL_ID_KEY, queueEntry.getQueueId().getValue());
try {
- queue.setExternalIds(ImmutableMap.copyOf(externalIdsMap));
+ YangUtils.copyYangKeyValueListToMap(externalIdsMap, queueEntry.getQueuesExternalIds(),
+ QueuesExternalIds::getQueuesExternalIdKey, QueuesExternalIds::getQueuesExternalIdValue);
} catch (NullPointerException e) {
LOG.warn("Incomplete Queue external IDs", e);
}
+ externalIdsMap.put(SouthboundConstants.QUEUE_ID_EXTERNAL_ID_KEY, queueEntry.getQueueId().getValue());
+ queue.setExternalIds(externalIdsMap);
- List<QueuesOtherConfig> otherConfigs = queueEntry.getQueuesOtherConfig();
- if (otherConfigs != null) {
- Map<String, String> otherConfigsMap = new HashMap<>();
- for (QueuesOtherConfig otherConfig : otherConfigs) {
- otherConfigsMap.put(otherConfig.getQueueOtherConfigKey(), otherConfig.getQueueOtherConfigValue());
- }
- try {
- queue.setOtherConfig(ImmutableMap.copyOf(otherConfigsMap));
- } catch (NullPointerException e) {
- LOG.warn("Incomplete Queue other_config", e);
- }
+ try {
+ queue.setOtherConfig(YangUtils.convertYangKeyValueListToMap(queueEntry.getQueuesOtherConfig(),
+ QueuesOtherConfig::getQueueOtherConfigKey, QueuesOtherConfig::getQueueOtherConfigValue));
+ } catch (NullPointerException e) {
+ LOG.warn("Incomplete Queue other_config", e);
}
if (uuid == null) {
transaction.add(op.insert(queue)).build();
/*
- * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015, 2016 Brocade Communications 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,
import org.opendaylight.ovsdb.southbound.SouthboundConstants;
import org.opendaylight.ovsdb.southbound.SouthboundMapper;
import org.opendaylight.ovsdb.southbound.SouthboundProvider;
+import org.opendaylight.ovsdb.utils.yang.YangUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbPortInterfaceAttributes.VlanMode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfd;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceLldp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceOtherConfigs;
import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.CheckedFuture;
createInterfaceOtherConfig(terminationPoint, ovsInterface);
createInterfaceExternalIds(terminationPoint, ovsInterface);
createInterfaceLldp(terminationPoint, ovsInterface);
+ createInterfaceBfd(terminationPoint, ovsInterface);
}
private void createInterfaceType(final OvsdbTerminationPointAugmentation terminationPoint,
//Configure optional input
if (terminationPoint.getOptions() != null) {
- Map<String, String> optionsMap = new HashMap<>();
- for (Options option : terminationPoint.getOptions()) {
- optionsMap.put(option.getOption(), option.getValue());
- }
try {
- ovsInterface.setOptions(ImmutableMap.copyOf(optionsMap));
+ ovsInterface.setOptions(YangUtils.convertYangKeyValueListToMap(terminationPoint.getOptions(),
+ Options::getOption, Options::getValue));
} catch (NullPointerException e) {
LOG.warn("Incomplete OVSDB interface options", e);
}
List<InterfaceExternalIds> interfaceExternalIds =
terminationPoint.getInterfaceExternalIds();
if (interfaceExternalIds != null && !interfaceExternalIds.isEmpty()) {
- Map<String, String> externalIdsMap = new HashMap<>();
- for (InterfaceExternalIds externalId: interfaceExternalIds) {
- externalIdsMap.put(externalId.getExternalIdKey(), externalId.getExternalIdValue());
- }
try {
- ovsInterface.setExternalIds(ImmutableMap.copyOf(externalIdsMap));
+ ovsInterface.setExternalIds(YangUtils.convertYangKeyValueListToMap(interfaceExternalIds,
+ InterfaceExternalIds::getExternalIdKey, InterfaceExternalIds::getExternalIdValue));
} catch (NullPointerException e) {
LOG.warn("Incomplete OVSDB interface external_ids", e);
}
List<InterfaceLldp> interfaceLldpList =
terminationPoint.getInterfaceLldp();
if (interfaceLldpList != null && !interfaceLldpList.isEmpty()) {
- Map<String, String> interfaceLldpMap = new HashMap<>();
- for (InterfaceLldp interfaceLldp : interfaceLldpList) {
- interfaceLldpMap.put(interfaceLldp.getLldpKey(), interfaceLldp.getLldpValue());
- }
try {
- ovsInterface.setLldp(ImmutableMap.copyOf(interfaceLldpMap));
+ ovsInterface.setLldp(YangUtils.convertYangKeyValueListToMap(interfaceLldpList,
+ InterfaceLldp::getLldpKey, InterfaceLldp::getLldpValue));
} catch (NullPointerException e) {
LOG.warn("Incomplete OVSDB interface lldp", e);
}
}
}
+ private void createInterfaceBfd(final OvsdbTerminationPointAugmentation terminationPoint,
+ final Interface ovsInterface) {
+
+ try {
+ List<InterfaceBfd> interfaceBfdList = terminationPoint.getInterfaceBfd();
+ if (interfaceBfdList != null && !interfaceBfdList.isEmpty()) {
+ try {
+ ovsInterface.setBfd(YangUtils.convertYangKeyValueListToMap(interfaceBfdList,
+ InterfaceBfd::getBfdKey, InterfaceBfd::getBfdValue));
+ } catch (NullPointerException e) {
+ LOG.warn("Incomplete OVSDB interface bfd", e);
+ }
+ }
+ } catch (SchemaVersionMismatchException e) {
+ LOG.debug("bfd column for Interface Table unsupported for this version of ovsdb schema", e);
+ }
+ }
+
private void createPortExternalIds(
final OvsdbTerminationPointAugmentation terminationPoint,
final Port port) {
List<PortExternalIds> portExternalIds = terminationPoint.getPortExternalIds();
if (portExternalIds != null && !portExternalIds.isEmpty()) {
- Map<String, String> externalIdsMap = new HashMap<>();
- for (PortExternalIds externalId: portExternalIds) {
- externalIdsMap.put(externalId.getExternalIdKey(), externalId.getExternalIdValue());
- }
try {
- port.setExternalIds(ImmutableMap.copyOf(externalIdsMap));
+ port.setExternalIds(YangUtils.convertYangKeyValueListToMap(portExternalIds,
+ PortExternalIds::getExternalIdKey, PortExternalIds::getExternalIdValue));
} catch (NullPointerException e) {
LOG.warn("Incomplete OVSDB port external_ids", e);
}
List<PortOtherConfigs> portOtherConfigs =
terminationPoint.getPortOtherConfigs();
if (portOtherConfigs != null && !portOtherConfigs.isEmpty()) {
- Map<String, String> otherConfigsMap = new HashMap<>();
- for (PortOtherConfigs portOtherConfig : portOtherConfigs) {
- otherConfigsMap.put(portOtherConfig.getOtherConfigKey(),
- portOtherConfig.getOtherConfigValue());
- }
try {
- ovsPort.setOtherConfig(ImmutableMap.copyOf(otherConfigsMap));
+ ovsPort.setOtherConfig(YangUtils.convertYangKeyValueListToMap(portOtherConfigs,
+ PortOtherConfigs::getOtherConfigKey, PortOtherConfigs::getOtherConfigValue));
} catch (NullPointerException e) {
LOG.warn("Incomplete OVSDB port other_config", e);
}
/*
- * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015, 2016 Brocade Communications 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,
import org.opendaylight.ovsdb.schema.openvswitch.Interface;
import org.opendaylight.ovsdb.schema.openvswitch.Port;
import org.opendaylight.ovsdb.southbound.SouthboundConstants;
+import org.opendaylight.ovsdb.utils.yang.YangUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbPortInterfaceAttributes.VlanMode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfd;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceLldp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceOtherConfigs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
public class TerminationPointUpdateCommand extends AbstractTransactCommand {
updateInterfaceOtherConfig(terminationPoint, ovsInterface);
updateInterfaceExternalIds(terminationPoint, ovsInterface);
updateInterfaceLldp(terminationPoint, ovsInterface);
+ updateInterfaceBfd(terminationPoint, ovsInterface);
}
private void updatePort(
//Configure optional input
if (terminationPoint.getOptions() != null) {
- Map<String, String> optionsMap = new HashMap<>();
- for (Options option : terminationPoint.getOptions()) {
- optionsMap.put(option.getOption(), option.getValue());
- }
try {
- ovsInterface.setOptions(ImmutableMap.copyOf(optionsMap));
+ ovsInterface.setOptions(YangUtils.convertYangKeyValueListToMap(terminationPoint.getOptions(),
+ Options::getOption, Options::getValue));
} catch (NullPointerException e) {
LOG.warn("Incomplete OVSDB interface options", e);
}
List<InterfaceExternalIds> interfaceExternalIds =
terminationPoint.getInterfaceExternalIds();
if (interfaceExternalIds != null && !interfaceExternalIds.isEmpty()) {
- Map<String, String> externalIdsMap = new HashMap<>();
- for (InterfaceExternalIds externalId: interfaceExternalIds) {
- externalIdsMap.put(externalId.getExternalIdKey(), externalId.getExternalIdValue());
- }
try {
- ovsInterface.setExternalIds(ImmutableMap.copyOf(externalIdsMap));
+ ovsInterface.setExternalIds(YangUtils.convertYangKeyValueListToMap(interfaceExternalIds,
+ InterfaceExternalIds::getExternalIdKey, InterfaceExternalIds::getExternalIdValue));
} catch (NullPointerException e) {
LOG.warn("Incomplete OVSDB interface external_ids", e);
}
List<InterfaceLldp> interfaceLldpList =
terminationPoint.getInterfaceLldp();
if (interfaceLldpList != null && !interfaceLldpList.isEmpty()) {
- Map<String, String> interfaceLldpMap = new HashMap<>();
- for (InterfaceLldp interfaceLldp : interfaceLldpList) {
- interfaceLldpMap.put(interfaceLldp.getLldpKey(), interfaceLldp.getLldpValue());
- }
try {
- ovsInterface.setLldp(ImmutableMap.copyOf(interfaceLldpMap));
+ ovsInterface.setLldp(YangUtils.convertYangKeyValueListToMap(interfaceLldpList,
+ InterfaceLldp::getLldpKey, InterfaceLldp::getLldpValue));
} catch (NullPointerException e) {
LOG.warn("Incomplete OVSDB interface lldp", e);
}
}
}
+ private void updateInterfaceBfd(
+ final OvsdbTerminationPointAugmentation terminationPoint,
+ final Interface ovsInterface) {
+
+ try {
+ List<InterfaceBfd> interfaceBfdList =
+ terminationPoint.getInterfaceBfd();
+ if (interfaceBfdList != null && !interfaceBfdList.isEmpty()) {
+ try {
+ ovsInterface.setBfd(YangUtils.convertYangKeyValueListToMap(interfaceBfdList,
+ InterfaceBfd::getBfdKey, InterfaceBfd::getBfdValue));
+ } catch (NullPointerException e) {
+ LOG.warn("Incomplete OVSDB interface bfd", e);
+ }
+ }
+ } catch (SchemaVersionMismatchException e) {
+ LOG.debug("bfd column for Interface Table unsupported for this version of ovsdb schema", e);
+ }
+ }
+
private void updatePortExternalIds(
final OvsdbTerminationPointAugmentation terminationPoint,
final Port port) {
List<PortExternalIds> portExternalIds = terminationPoint.getPortExternalIds();
if (portExternalIds != null && !portExternalIds.isEmpty()) {
- Map<String, String> externalIdsMap = new HashMap<>();
- for (PortExternalIds externalId: portExternalIds) {
- externalIdsMap.put(externalId.getExternalIdKey(), externalId.getExternalIdValue());
- }
try {
- port.setExternalIds(ImmutableMap.copyOf(externalIdsMap));
+ port.setExternalIds(YangUtils.convertYangKeyValueListToMap(portExternalIds,
+ PortExternalIds::getExternalIdKey, PortExternalIds::getExternalIdValue));
} catch (NullPointerException e) {
LOG.warn("Incomplete OVSDB port external_ids", e);
}
List<PortOtherConfigs> portOtherConfigs =
terminationPoint.getPortOtherConfigs();
if (portOtherConfigs != null && !portOtherConfigs.isEmpty()) {
- Map<String, String> otherConfigsMap = new HashMap<>();
- for (PortOtherConfigs portOtherConfig : portOtherConfigs) {
- otherConfigsMap.put(portOtherConfig.getOtherConfigKey(),
- portOtherConfig.getOtherConfigValue());
- }
try {
- ovsPort.setOtherConfig(ImmutableMap.copyOf(otherConfigsMap));
+ ovsPort.setOtherConfig(YangUtils.convertYangKeyValueListToMap(portOtherConfigs,
+ PortOtherConfigs::getOtherConfigKey, PortOtherConfigs::getOtherConfigValue));
} catch (NullPointerException e) {
LOG.warn("Incomplete OVSDB port other_config", e);
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ManagedNodeEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfd;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdStatusBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdStatusKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIdsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceLldp;
updateOptions(interf, ovsdbTerminationPointBuilder);
updateInterfaceOtherConfig(interf, ovsdbTerminationPointBuilder);
updateInterfaceLldp(interf, ovsdbTerminationPointBuilder);
+ updateInterfaceBfd(interf, ovsdbTerminationPointBuilder);
+ updateInterfaceBfdStatus(interf, ovsdbTerminationPointBuilder);
}
private void updateVlan(final Port port,
}
}
+ private void updateInterfaceBfdStatus(final Interface interf,
+ final OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointBuilder) {
+
+ try {
+ Map<String, String> interfaceBfdStatusMap = interf.getBfdStatusColumn().getData();
+ if (interfaceBfdStatusMap != null && !interfaceBfdStatusMap.isEmpty()) {
+ List<InterfaceBfdStatus> interfaceBfdStatusList = new ArrayList<>();
+ for (String interfaceBfdStatusKeyString : interfaceBfdStatusMap.keySet()) {
+ String interfaceBfdStatusValueString = interfaceBfdStatusMap.get(interfaceBfdStatusKeyString);
+ if (interfaceBfdStatusKeyString != null && interfaceBfdStatusValueString!=null) {
+ interfaceBfdStatusList.add(new InterfaceBfdStatusBuilder()
+ .setKey(new InterfaceBfdStatusKey(interfaceBfdStatusKeyString))
+ .setBfdStatusKey(interfaceBfdStatusKeyString)
+ .setBfdStatusValue(interfaceBfdStatusValueString)
+ .build());
+ }
+ }
+ ovsdbTerminationPointBuilder.setInterfaceBfdStatus(interfaceBfdStatusList);
+ }
+ } catch (SchemaVersionMismatchException e) {
+ // We don't care about the exception stack trace here
+ LOG.debug("bfd-status column for Interface Table unsupported for this version of ovsdb schema. {}", e.getMessage());
+ }
+ }
+
+ private void updateInterfaceBfd(final Interface interf,
+ final OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointBuilder) {
+
+ try {
+ Map<String, String> interfaceBfdMap = interf.getBfdColumn().getData();
+ if (interfaceBfdMap != null && !interfaceBfdMap.isEmpty()) {
+ List<InterfaceBfd> interfaceBfdList = new ArrayList<>();
+ for (String interfaceBfdKeyString : interfaceBfdMap.keySet()) {
+ String interfaceBfdValueString = interfaceBfdMap.get(interfaceBfdKeyString);
+ if (interfaceBfdKeyString != null && interfaceBfdValueString!=null) {
+ interfaceBfdList.add(new InterfaceBfdBuilder()
+ .setKey(new InterfaceBfdKey(interfaceBfdKeyString))
+ .setBfdKey(interfaceBfdKeyString)
+ .setBfdValue(interfaceBfdValueString)
+ .build());
+ }
+ }
+ ovsdbTerminationPointBuilder.setInterfaceBfd(interfaceBfdList);
+ }
+ } catch (SchemaVersionMismatchException e) {
+ // We don't care about the exception stack trace here
+ LOG.debug("bfd column for Interface Table unsupported for this version of ovsdb schema. {}", e.getMessage());
+ }
+ }
+
private boolean portQosCleared(Entry<UUID, Port> portUpdate) {
if (portUpdate.getValue().getQosColumn() == null) {
return false;
MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateOptions", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterfaceOtherConfig", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterfaceLldp", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
+ MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterfaceBfd", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
+ MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterfaceBfdStatus", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
Whitebox.invokeMethod(ovsdbPortUpdateCommand, "updateInterface", interf, OVSDB_INTERFACE_TYPE, ovsdbTerminationPointBuilder);
verify(ovsdbTerminationPointBuilder).setInterfaceUuid(any(Uuid.class));
<module>servicehelper</module>
<module>southbound-utils</module>
<module>hwvtepsouthbound-utils</module>
+ <module>yang-utils</module>
</modules>
<!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.odlparent</groupId>
+ <artifactId>bundle-parent</artifactId>
+ <version>1.7.0-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>utils.yang-utils</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>jsr305</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.opendaylight.ovsdb.utils.yang
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+/*
+ * Copyright © 2016 Red Hat, Inc. and others.
+ *
+ * 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.utils.yang;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.Function;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * YANG utility functions.
+ */
+public final class YangUtils {
+ /**
+ * Prevent instantiation.
+ */
+ private YangUtils() {
+ // Nothing to do
+ }
+
+ /**
+ * Copies a list of YANG key-value items to the given map. Any {@code null} key or value will cause an error.
+ *
+ * @param map The map to fill.
+ * @param yangList The list of YANG key-value items.
+ * @param keyExtractor The key extractor function to use.
+ * @param valueExtractor The value extractor function to use.
+ * @param <T> The YANG item type.
+ * @param <K> The key type.
+ * @param <V> The value type.
+ * @return The map.
+ */
+ @Nonnull
+ public static <T, K, V> Map<K, V> copyYangKeyValueListToMap(@Nonnull Map<K, V> map, @Nullable Iterable<T> yangList,
+ @Nonnull Function<T, K> keyExtractor,
+ @Nonnull Function<T, V> valueExtractor) {
+ if (yangList != null) {
+ for (T yangValue : yangList) {
+ K key = keyExtractor.apply(yangValue);
+ V value = valueExtractor.apply(yangValue);
+ Preconditions.checkNotNull(key);
+ Preconditions.checkNotNull(value);
+ map.put(key, value);
+ }
+ }
+ return map;
+ }
+
+ /**
+ * Converts a list of YANG key-value items to a map.
+ *
+ * @param yangList The list of YANG key-value items.
+ * @param keyExtractor The key extractor function to use.
+ * @param valueExtractor The value extractor function to use.
+ * @param <T> The YANG item type.
+ * @param <K> The key type.
+ * @param <V> The value type.
+ * @return The map.
+ */
+ @Nonnull
+ public static <T, K, V> Map<K, V> convertYangKeyValueListToMap(@Nullable Iterable<T> yangList,
+ @Nonnull Function<T, K> keyExtractor,
+ @Nonnull Function<T, V> valueExtractor) {
+ return copyYangKeyValueListToMap(new HashMap<>(), yangList, keyExtractor, valueExtractor);
+ }
+}