input.getName(), network);
return;
}
+ NeutronvpnUtils.addToPortCache(input);
+
/* check if router interface has been created */
if ((input.getDeviceOwner() != null) && (input.getDeviceId() != null)) {
if (input.getDeviceOwner().equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF)) {
return;
}
}
- handleNeutronPortCreated(input);
- NeutronvpnUtils.addToPortCache(input);
+ if (input.getFixedIps() != null && !input.getFixedIps().isEmpty()) {
+ handleNeutronPortCreated(input);
+ }
}
input.getName(), network);
return;
}
+ NeutronvpnUtils.removeFromPortCache(input);
+
if ((input.getDeviceOwner() != null) && (input.getDeviceId() != null)) {
if (input.getDeviceOwner().equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF)) {
handleRouterInterfaceRemoved(input);
return;
}
}
- handleNeutronPortDeleted(input);
- NeutronvpnUtils.removeFromPortCache(input);
+ if (input.getFixedIps() != null && !input.getFixedIps().isEmpty()) {
+ handleNeutronPortDeleted(input);
+ }
}
@Override
if (NeutronvpnUtils.isPortVifTypeUpdated(original, update)) {
updateOfPortInterface(original, update);
}
+ NeutronvpnUtils.addToPortCache(update);
/* check if router interface has been updated */
if ((update.getDeviceOwner() != null) && (update.getDeviceId() != null)) {
}
}
handleNeutronPortUpdated(original, update);
- NeutronvpnUtils.addToPortCache(update);
}
-
handlePortSecurityUpdated(original, update);
}
}
private void handleNeutronPortUpdated(Port portoriginal, Port portupdate) {
+ if (portoriginal.getFixedIps() == null || portoriginal.getFixedIps().isEmpty()) {
+ handleNeutronPortCreated(portupdate);
+ return;
+ }
LOG.debug("Add port to subnet");
// add port FixedIP to local Subnets DS
Uuid vpnIdup = addPortToSubnets(portupdate);
public List<String> showNeutronPortsCLI() {
List<String> result = new ArrayList<>();
- result.add(String.format(" %-34s %-22s %-22s %-6s ", "PortName", "Mac Address", "IP Address",
- "Prefix Length"));
- result.add("---------------------------------------------------------------------------------------");
+ result.add(String.format(" %-36s %-19s %-13s %-20s ", "Port ID", "Mac Address", "Prefix Length", "IP " +
+ "Address"));
+ result.add("-------------------------------------------------------------------------------------------");
InstanceIdentifier<Ports> portidentifier = InstanceIdentifier.create(Neutron.class).child(Ports.class);
try {
Optional<Ports> ports = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION, portidentifier);
if (ports.isPresent() && ports.get().getPort() != null) {
for (Port port : ports.get().getPort()) {
- if (port.getFixedIps() != null && !port.getFixedIps().isEmpty()) {
- result.add(String.format(" %-34s %-22s %-22s %-6s ", port.getUuid().getValue(), port
- .getMacAddress(), port.getFixedIps().get(0).getIpAddress().getIpv4Address().
- getValue(), NeutronvpnUtils.getIPPrefixFromPort(broker, port)));
+ List<FixedIps> fixedIPs = port.getFixedIps();
+ try {
+ if (fixedIPs != null && !fixedIPs.isEmpty()) {
+ List<String> ipList = new ArrayList<>();
+ for (FixedIps fixedIp : fixedIPs) {
+ IpAddress ipAddress = fixedIp.getIpAddress();
+ if (ipAddress.getIpv4Address() != null) {
+ ipList.add(ipAddress.getIpv4Address().getValue());
+ } else {
+ ipList.add((ipAddress.getIpv6Address().getValue()));
+ }
+ }
+ result.add(String.format(" %-36s %-19s %-13s %-20s ", port.getUuid().getValue(), port
+ .getMacAddress().getValue(), NeutronvpnUtils.getIPPrefixFromPort(broker, port),
+ ipList.toString()));
+ } else {
+ result.add(String.format(" %-36s %-19s %-13s %-20s ", port.getUuid().getValue(), port
+ .getMacAddress().getValue(), "Not Assigned", "Not Assigned"));
+ }
+ } catch (Exception e) {
+ logger.error("Failed to retrieve neutronPorts info for port {}: ", port.getUuid().getValue(),
+ e);
+ System.out.println("Failed to retrieve neutronPorts info for port: " + port.getUuid()
+ .getValue() + ": " + e.getMessage());
}
}
}