X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=hwvtepsouthbound%2Fhwvtepsouthbound-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fovsdb%2Fhwvtepsouthbound%2Ftransact%2FUcastMacsLocalUpdateCommand.java;h=f9a161e81a1137d3e0c601cb923b14aeac863729;hb=c4c8855d4a7abfb7680c13b904e564e380188d8b;hp=ee1106b333af80b19ccfefc9cecb02160888c8a5;hpb=2af45602984a8c2d12d99c437727114efa2be18d;p=ovsdb.git diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalUpdateCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalUpdateCommand.java index ee1106b33..f9a161e81 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalUpdateCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalUpdateCommand.java @@ -1,5 +1,5 @@ /* - * 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, @@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory; 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> changes) { @@ -74,34 +74,42 @@ public class UcastMacsLocalUpdateCommand extends AbstractTransactCommand { UcastMacsLocal ucastMacsLocal = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), UcastMacsLocal.class); setIpAddress(ucastMacsLocal, localUcastMac); setLocator(transaction, ucastMacsLocal, localUcastMac); - setLogicalSwitch(instanceIdentifier, ucastMacsLocal, localUcastMac); + setLogicalSwitch(ucastMacsLocal, localUcastMac); if (!operationalMacOptional.isPresent()) { setMac(ucastMacsLocal, localUcastMac, operationalMacOptional); + LOG.trace("execute: creating LocalUcastMac entry: {}", ucastMacsLocal); transaction.add(op.insert(ucastMacsLocal)); - } else { - LocalUcastMacs updatedMac = operationalMacOptional.get(); - String existingMac = updatedMac.getMacEntryKey().getValue(); - UcastMacsLocal extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), UcastMacsLocal.class); - extraMac.setMac("");; + transaction.add(op.comment("UcastMacLocal: Creating " + localUcastMac.getMacEntryKey().getValue())); + } else if (operationalMacOptional.get().getMacEntryUuid() != null) { + UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue()); + UcastMacsLocal extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), + UcastMacsLocal.class, null); + extraMac.getUuidColumn().setData(macEntryUUID); + LOG.trace("execute: updating LocalUcastMac entry: {}", ucastMacsLocal); transaction.add(op.update(ucastMacsLocal) - .where(extraMac.getMacColumn().getSchema().opEqual(existingMac)) + .where(extraMac.getUuidColumn().getSchema().opEqual(macEntryUUID)) .build()); + transaction.add(op.comment("UcastMacLocal: Updating " + macEntryUUID)); + } else { + LOG.warn("Unable to update localUcastMacs {} because uuid not found in the operational store", + localUcastMac.getMacEntryKey().getValue()); } } } - private void setLogicalSwitch(InstanceIdentifier iid, UcastMacsLocal ucastMacsLocal, LocalUcastMacs inputMac) { + private void setLogicalSwitch(UcastMacsLocal ucastMacsLocal, LocalUcastMacs inputMac) { if (inputMac.getLogicalSwitchRef() != null) { - HwvtepNodeName lswitchName = new HwvtepNodeName(inputMac.getLogicalSwitchRef().getValue()); + @SuppressWarnings("unchecked") + InstanceIdentifier lswitchIid = (InstanceIdentifier) inputMac.getLogicalSwitchRef().getValue(); Optional operationalSwitchOptional = - getOperationalState().getLogicalSwitches(iid, new LogicalSwitchesKey(lswitchName)); + getOperationalState().getLogicalSwitches(lswitchIid); if (operationalSwitchOptional.isPresent()) { Uuid logicalSwitchUuid = operationalSwitchOptional.get().getLogicalSwitchUuid(); UUID logicalSwitchUUID = new UUID(logicalSwitchUuid.getValue()); ucastMacsLocal.setLogicalSwitch(logicalSwitchUUID); } else { - LOG.warn("Create or update localUcastMacs: No logical switch named {} found in operational datastore!", - lswitchName); + LOG.warn("Create or update localUcastMacs: No logical switch with iid {} found in operational datastore!", + lswitchIid); } } }