*/
package org.opendaylight.ovsdb.openstack.netvirt;
-import org.opendaylight.controller.networkconfig.neutron.INeutronPortAware;
-import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
+import org.opendaylight.neutron.spi.INeutronPortAware;
+import org.opendaylight.neutron.spi.NeutronPort;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.ovsdb.lib.notation.Row;
import org.opendaylight.ovsdb.lib.notation.UUID;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
-import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
-import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
-import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener;
+import org.opendaylight.ovsdb.openstack.netvirt.impl.NeutronL3Adapter;
+import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbConfigurationService;
+import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbConnectionService;
+import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbInventoryListener;
import org.opendaylight.ovsdb.schema.openvswitch.Interface;
import org.opendaylight.ovsdb.schema.openvswitch.Port;
private volatile OvsdbConfigurationService ovsdbConfigurationService;
private volatile OvsdbConnectionService connectionService;
private volatile OvsdbInventoryListener ovsdbInventoryListener;
+ private volatile NeutronL3Adapter neutronL3Adapter;
/**
* Invoked when a port creation is requested
* @param port An instance of new Neutron Port object.
*/
@Override
- public void neutronPortCreated(NeutronPort port) {
- int result = canCreatePort(port);
+ public void neutronPortCreated(NeutronPort neutronPort) {
+ int result = canCreatePort(neutronPort);
if (result != HttpURLConnection.HTTP_CREATED) {
logger.error(" Port create validation failed result - {} ", result);
return;
}
- enqueueEvent(new NorthboundEvent(port, NorthboundEvent.Action.ADD));
+ enqueueEvent(new NorthboundEvent(neutronPort, Action.ADD));
}
- private void doNeutronPortCreated(NeutronPort port) {
+ private void doNeutronPortCreated(NeutronPort neutronPort) {
logger.debug(" Port-ADD successful for tenant-id - {}," +
" network-id - {}, port-id - {}",
- port.getTenantID(), port.getNetworkUUID(),
- port.getID());
+ neutronPort.getTenantID(), neutronPort.getNetworkUUID(),
+ neutronPort.getID());
+ neutronL3Adapter.handleNeutronPortEvent(neutronPort, Action.ADD);
}
/**
* @param port An instance of modified Neutron Port object.
*/
@Override
- public void neutronPortUpdated(NeutronPort port) {
+ public void neutronPortUpdated(NeutronPort neutronPort) {
+ enqueueEvent(new NorthboundEvent(neutronPort, Action.UPDATE));
+ }
+ private void doNeutronPortUpdated(NeutronPort neutronPort) {
+ logger.debug("Handling neutron update port " + neutronPort);
+ neutronL3Adapter.handleNeutronPortEvent(neutronPort, Action.UPDATE);
}
/**
return;
}
- enqueueEvent(new NorthboundEvent(neutronPort, NorthboundEvent.Action.DELETE));
+ enqueueEvent(new NorthboundEvent(neutronPort, Action.DELETE));
}
private void doNeutronPortDeleted(NeutronPort neutronPort) {
logger.debug("Handling neutron delete port " + neutronPort);
+ neutronL3Adapter.handleNeutronPortEvent(neutronPort, Action.DELETE);
List<Node> nodes = connectionService.getNodes();
for (Node node : nodes) {
for (Row portRow : portRows.values()) {
Port port = ovsdbConfigurationService.getTypedRow(node, Port.class, portRow);
for (UUID interfaceUuid : port.getInterfacesColumn().getData()) {
- Interface interfaceRow = (Interface) ovsdbConfigurationService
+ Row ifaceRow = ovsdbConfigurationService
.getRow(node,
ovsdbConfigurationService.getTableName(node, Interface.class),
interfaceUuid.toString());
-
- Map<String, String> externalIds = interfaceRow.getExternalIdsColumn().getData();
+ Interface iface = ovsdbConfigurationService.getTypedRow(node, Interface.class, ifaceRow);
+ Map<String, String> externalIds = iface.getExternalIdsColumn().getData();
if (externalIds == null) {
- logger.trace("No external_ids seen in {}", interfaceRow);
+ logger.trace("No external_ids seen in {}", iface.getName());
continue;
}
}
if (neutronPortId.equalsIgnoreCase(neutronPort.getPortUUID())) {
- logger.trace("neutronPortDeleted: Delete interface {}", interfaceRow.getName());
+ logger.trace("neutronPortDeleted: Delete interface {}", iface.getName());
ovsdbConfigurationService.deleteRow(node,
ovsdbConfigurationService.getTableName(node, Port.class),
port.getUuid().toString());
}
}
} catch (Exception e) {
- logger.error("Exception during handlingNeutron network delete");
+ logger.error("Exception during handlingNeutron port delete", e);
}
}
logger.debug(" PORT delete successful for tenant-id - {}, " +
case DELETE:
doNeutronPortDeleted(ev.getPort());
break;
+ case UPDATE:
+ doNeutronPortUpdated(ev.getPort());
+ break;
default:
logger.warn("Unable to process event action " + ev.getAction());
break;