import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelIps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelIpsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelIpsKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelsBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
private static final Logger LOG = LoggerFactory.getLogger(PhysicalSwitchUpdateCommand.class);
private Map<UUID, PhysicalSwitch> updatedPSRows;
- private Map<UUID, PhysicalSwitch> oldPSRows;
- public PhysicalSwitchUpdateCommand(HwvtepConnectionInstance key, TableUpdates updates,
- DatabaseSchema dbSchema) {
+ public PhysicalSwitchUpdateCommand(HwvtepConnectionInstance key, TableUpdates updates, DatabaseSchema dbSchema) {
super(key, updates, dbSchema);
- updatedPSRows = TyperUtils.extractRowsUpdated(PhysicalSwitch.class, getUpdates(),getDbSchema());
- oldPSRows = TyperUtils.extractRowsOld(PhysicalSwitch.class, getUpdates(),getDbSchema());
+ updatedPSRows = TyperUtils.extractRowsUpdated(PhysicalSwitch.class, getUpdates(), getDbSchema());
}
@Override
public void execute(ReadWriteTransaction transaction) {
- if(updatedPSRows != null && !updatedPSRows.isEmpty()) {
- for (Entry<UUID, PhysicalSwitch> entry : updatedPSRows.entrySet()) {
- updatePhysicalSwitch(transaction, entry.getValue());
- }
+ for (PhysicalSwitch physicalSwitch : updatedPSRows.values()) {
+ updatePhysicalSwitch(transaction, physicalSwitch);
}
}
final InstanceIdentifier<Node> connectionIId = getOvsdbConnectionInstance().getInstanceIdentifier();
Optional<Node> connection = HwvtepSouthboundUtil.readNode(transaction, connectionIId);
if (connection.isPresent()) {
- LOG.debug("Connection {} is present",connection);
+ LOG.debug("Connection {} is present", connection);
// Update the connection node to let it know it manages this Physical Switch
Node connectionNode = buildConnectionNode(pSwitch);
transaction.merge(LogicalDatastoreType.OPERATIONAL, connectionIId, connectionNode);
InstanceIdentifier<Node> psIid = getInstanceIdentifier(pSwitch);
Node psNode = buildPhysicalSwitchNode(pSwitch);
transaction.merge(LogicalDatastoreType.OPERATIONAL, psIid, psNode);
-// TODO: Delete entries that are no longer needed
+ // TODO: Delete entries that are no longer needed
}
}
psNodeBuilder.setNodeId(psNodeId);
PhysicalSwitchAugmentationBuilder psAugmentationBuilder = new PhysicalSwitchAugmentationBuilder();
psAugmentationBuilder.setPhysicalSwitchUuid(new Uuid(pSwitch.getUuid().toString()));
- setManagedBy(psAugmentationBuilder, pSwitch);
+ setManagedBy(psAugmentationBuilder);
setPhysicalSwitchId(psAugmentationBuilder, pSwitch);
setManagementIps(psAugmentationBuilder, pSwitch);
setTunnelIps(psAugmentationBuilder, pSwitch);
return psNodeBuilder.build();
}
- private void setManagedBy(PhysicalSwitchAugmentationBuilder psAugmentationBuilder, PhysicalSwitch pSwitch) {
+ private void setManagedBy(PhysicalSwitchAugmentationBuilder psAugmentationBuilder) {
InstanceIdentifier<Node> connectionNodePath = getOvsdbConnectionInstance().getInstanceIdentifier();
psAugmentationBuilder.setManagedBy(new HwvtepGlobalRef(connectionNodePath));
}
private void setPhysicalSwitchId(PhysicalSwitchAugmentationBuilder psAugmentationBuilder, PhysicalSwitch pSwitch) {
- if(pSwitch.getName() != null) {
+ if (pSwitch.getName() != null) {
psAugmentationBuilder.setHwvtepNodeName(new HwvtepNodeName(pSwitch.getName()));
}
- if(pSwitch.getDescription() != null) {
+ if (pSwitch.getDescription() != null) {
psAugmentationBuilder.setHwvtepNodeDescription(pSwitch.getDescription());
}
}
private void setManagementIps(PhysicalSwitchAugmentationBuilder psAugmentationBuilder, PhysicalSwitch pSwitch) {
- if(pSwitch.getManagementIpsColumn() != null
+ if (pSwitch.getManagementIpsColumn() != null
&& pSwitch.getManagementIpsColumn().getData() != null
- && !pSwitch.getManagementIpsColumn().getData().isEmpty() ) {
+ && !pSwitch.getManagementIpsColumn().getData().isEmpty()) {
List<ManagementIps> mgmtIps = new ArrayList<>();
- for(String mgmtIp: pSwitch.getManagementIpsColumn().getData()) {
+ for (String mgmtIp : pSwitch.getManagementIpsColumn().getData()) {
IpAddress ip = new IpAddress(mgmtIp.toCharArray());
mgmtIps.add(new ManagementIpsBuilder()
.setKey(new ManagementIpsKey(ip))
}
private void setTunnelIps(PhysicalSwitchAugmentationBuilder psAugmentationBuilder, PhysicalSwitch pSwitch) {
- if(pSwitch.getTunnelIpsColumn() != null
- && pSwitch.getTunnelIpsColumn().getData() != null
- && !pSwitch.getTunnelIpsColumn().getData().isEmpty()) {
+ if (pSwitch.getTunnelIpsColumn() != null
+ && pSwitch.getTunnelIpsColumn().getData() != null
+ && !pSwitch.getTunnelIpsColumn().getData().isEmpty()) {
List<TunnelIps> tunnelIps = new ArrayList<>();
- for(String tunnelIp: pSwitch.getTunnelIpsColumn().getData()) {
+ for (String tunnelIp : pSwitch.getTunnelIpsColumn().getData()) {
IpAddress ip = new IpAddress(tunnelIp.toCharArray());
tunnelIps.add(new TunnelIpsBuilder()
.setKey(new TunnelIpsKey(ip))
private void setUcastMacsLocal(PhysicalSwitchAugmentationBuilder psAugmentationBuilder, PhysicalSwitch pSwitch) {
// TODO Auto-generated method stub
-
+
}
private void setUcastMacsRemote(PhysicalSwitchAugmentationBuilder psAugmentationBuilder, PhysicalSwitch pSwitch) {
// TODO Auto-generated method stub
-
+
}
private void setMcastMacsLocal(PhysicalSwitchAugmentationBuilder psAugmentationBuilder, PhysicalSwitch pSwitch) {
// TODO Auto-generated method stub
-
+
}
private void setMcastMacsRemote(PhysicalSwitchAugmentationBuilder psAugmentationBuilder, PhysicalSwitch pSwitch) {
// TODO Auto-generated method stub
-
+
}
private Node buildConnectionNode(PhysicalSwitch pSwitch) {
HwvtepGlobalAugmentationBuilder hgAugmentationBuilder = new HwvtepGlobalAugmentationBuilder();
List<Switches> switches = new ArrayList<>();
- InstanceIdentifier<Node> switchIid = HwvtepSouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(),
- pSwitch);
+ InstanceIdentifier<Node> switchIid =
+ HwvtepSouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(), pSwitch);
hgAugmentationBuilder.setSwitches(switches);
Switches physicalSwitch = new SwitchesBuilder().setSwitchRef(
- new HwvtepPhysicalSwitchRef(switchIid)).build();
+ new HwvtepPhysicalSwitchRef(switchIid)).build();
switches.add(physicalSwitch);
connectionNode.addAugmentation(HwvtepGlobalAugmentation.class, hgAugmentationBuilder.build());
}
private NodeId getNodeId(PhysicalSwitch pSwitch) {
- NodeKey nodeKey = getInstanceIdentifier(pSwitch).firstKeyOf(Node.class, NodeKey.class);
+ NodeKey nodeKey = getInstanceIdentifier(pSwitch).firstKeyOf(Node.class);
return nodeKey.getNodeId();
}
}