/*
- * 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));
- } 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());
}
}
}