- // adds port to subnet list and creates vpnInterface
- private Uuid addPortToSubnets(Port port) {
- Uuid subnetId = null;
- Uuid vpnId = null;
- String name = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
-
- // find all Subnets to which this port is associated,
- List<FixedIps> ips = port.getFixedIps();
- for (FixedIps ip : ips) {
- String ipValue = ip.getIpAddress().getIpv4Address().getValue();
-
- InstanceIdentifier id = NeutronvpnUtils.buildFixedIpToPortNameIdentifier(ipValue);
- PortFixedipToPortNameBuilder builder = new PortFixedipToPortNameBuilder().setPortFixedip(ipValue)
- .setPortName(name);
- MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, id, builder.build());
- logger.debug("fixedIp-name map for neutron port with fixedIp: {}, name: {} added to NeutronPortData DS",
- ipValue, name);
-
- subnetId = ip.getSubnetId();
- Subnetmap subnetmap = updateSubnetNode(subnetId, null, null, null, null, port.getUuid());
- if (vpnId == null && subnetmap != null) {
- vpnId = subnetmap.getVpnId();
- }
- }
- return vpnId;
- }
-
- private Uuid removePortFromSubnets(Port port) {
- Uuid subnetId = null;
- Uuid vpnId = null;
-
- // find all Subnets to which this port is associated,
- List<FixedIps> ips = port.getFixedIps();
- for (FixedIps ip : ips) {
- String ipValue = ip.getIpAddress().getIpv4Address().getValue();
-
- InstanceIdentifier id = NeutronvpnUtils.buildFixedIpToPortNameIdentifier(ipValue);
- MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, id);
- logger.debug("fixedIp-name map for neutron port with fixedIp: {} deleted from NeutronPortData DS",
- ipValue);
-
- subnetId = ip.getSubnetId();
- Subnetmap subnetmap = removeFromSubnetNode(subnetId, null, null, null, port.getUuid());
- if (vpnId == null && subnetmap != null) {
- vpnId = subnetmap.getVpnId();
- }
- }
- return vpnId;
- }
-
- protected void handleNeutronPortCreated(Port port) {
- logger.info("Of-port-interface creation");
- int portVlanId = NeutronvpnUtils.getVlanFromNeutronPort(port);
- // Create of-port interface for this neutron port
- createOfPortInterface(port, portVlanId);
- logger.debug("Add port to subnet");
- // add port to local Subnets DS
- Uuid vpnId = addPortToSubnets(port);
-
- if (vpnId != null) {
- // create vpn-interface on this neutron port
- logger.debug("Adding VPN Interface");
- createVpnInterface(vpnId, port);
- }
- }
-
- protected void handleNeutronPortDeleted(Port port) {
- logger.debug("Of-port-interface removal");
- logger.debug("Remove port from subnet");
- // remove port from local Subnets DS
- Uuid vpnId = removePortFromSubnets(port);
-
- if (vpnId != null) {
- // remove vpn-interface for this neutron port
- logger.debug("removing VPN Interface");
- deleteVpnInterface(port);
- }
- int portVlanId = NeutronvpnUtils.getVlanFromNeutronPort(port);
- // Remove of-port interface for this neutron port
- deleteOfPortInterface(port, portVlanId);
-
- }
-
- protected void handleNeutronPortUpdated(Port portoriginal, Port portupdate) {
- logger.debug("Add port to subnet");
- // add port FixedIPs to local Subnets DS
- Uuid vpnIdup = addPortToSubnets(portupdate);
-
- if (vpnIdup != null) {
- createVpnInterface(vpnIdup, portupdate);
- }
-
- // remove port FixedIPs from local Subnets DS
- Uuid vpnIdor = removePortFromSubnets(portoriginal);
-
- if (vpnIdor != null) {
- deleteVpnInterface(portoriginal);
- }
- }
-