Search in sources :

Example 41 with Neutron

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron in project netvirt by opendaylight.

the class NeutronPortChangeListener method handleNeutronPortDeleted.

private void handleNeutronPortDeleted(final Port port) {
    final String portName = port.getUuid().getValue();
    final Uuid portId = port.getUuid();
    final List<FixedIps> portIpsList = port.getFixedIps();
    jobCoordinator.enqueueJob("PORT- " + portName, () -> {
        WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
        List<ListenableFuture<Void>> futures = new ArrayList<>();
        if (!(NeutronUtils.isPortVnicTypeNormal(port) || isPortTypeSwitchdev(port))) {
            for (FixedIps ip : portIpsList) {
                // remove direct port from subnetMaps config DS
                nvpnManager.removePortsFromSubnetmapNode(ip.getSubnetId(), null, portId);
            }
            LOG.info("Port {} is not a normal and not a direct with switchdev VNIC type ;" + "Skipping OF Port interfaces removal", portName);
            return futures;
        }
        Uuid vpnId = null;
        Set<Uuid> routerIds = new HashSet<>();
        Uuid internetVpnId = null;
        for (FixedIps ip : portIpsList) {
            Subnetmap subnetMap = nvpnManager.removePortsFromSubnetmapNode(ip.getSubnetId(), portId, null);
            if (subnetMap == null) {
                continue;
            }
            if (subnetMap.getVpnId() != null) {
                // can't use NeutronvpnUtils.getVpnForNetwork to optimise here, because it gives BGPVPN id
                // obtained subnetMaps belongs to one network => vpnId must be the same for each port Ip
                vpnId = subnetMap.getVpnId();
            }
            if (subnetMap.getRouterId() != null) {
                routerIds.add(subnetMap.getRouterId());
            }
            internetVpnId = subnetMap.getInternetVpnId();
        }
        if (vpnId != null || internetVpnId != null) {
            // remove vpn-interface for this neutron port
            LOG.debug("removing VPN Interface for port {}", portName);
            if (!routerIds.isEmpty()) {
                for (Uuid routerId : routerIds) {
                    nvpnManager.removeFromNeutronRouterInterfacesMap(routerId, portName);
                }
            }
            nvpnManager.deleteVpnInterface(portName, null, /* vpn-id */
            wrtConfigTxn);
        }
        // Remove of-port interface for this neutron port
        // ELAN interface is also implicitly deleted as part of this operation
        LOG.debug("Of-port-interface removal for port {}", portName);
        deleteOfPortInterface(port, wrtConfigTxn);
        // dissociate fixedIP from floatingIP if associated
        nvpnManager.dissociatefixedIPFromFloatingIP(port.getUuid().getValue());
        futures.add(wrtConfigTxn.submit());
        return futures;
    });
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) HashSet(java.util.HashSet)

Example 42 with Neutron

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron in project lispflowmapping by opendaylight.

the class PortDataProcessor method create.

@Override
public void create(Port port) {
    // TODO Consider adding Port MAC -> Port fixed IP in MS
    // host_ip exists in MS
    LOG.debug("Neutron Port Created : " + port.toString());
    final String hostId = port.getAugmentation(PortBindingExtension.class).getHostId();
    if (hostId == null) {
        LOG.error("Adding new Neutron port to lisp mapping service failed. Port does not have a HostID. Port: {}", port.toString());
        return;
    }
    List<FixedIps> fixedIPs = port.getFixedIps();
    if (fixedIPs != null && fixedIPs.size() > 0) {
        Eid eidAddress;
        for (FixedIps ip : fixedIPs) {
            // TODO Add check/support for IPv6.
            // Get subnet for this port, based on v4 or v6 decide address
            // iana code.
            eidAddress = getEid(port, ip);
            PortData portData = new PortData(port.getUuid().getValue(), eidAddress);
            hostInformationManager.addHostRelatedInfo(hostId, portData);
        }
    }
    LOG.info("Neutron Port Created: Port name: " + port.getName() + " Port Fixed IP: " + (port.getFixedIps() != null ? port.getFixedIps().get(0) : "No Fixed IP assigned"));
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) PortData(org.opendaylight.lispflowmapping.neutron.mappingmanager.PortData) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) PortBindingExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension)

Example 43 with Neutron

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron in project lispflowmapping by opendaylight.

the class SubnetDataProcessor method delete.

/**
 * Method removes the EID prefix and key associated with the deleted subnet
 * from Lisp mapping service.
 */
@Override
public void delete(Subnet subnet) {
    LOG.info("Neutron Subnet Deleted Request : Subnet name: " + subnet.getName() + " Subnet Cidr: " + subnet.getCidr() + "Key: " + subnet.getUuid());
    LOG.debug("Lisp Neutron Subnet: " + subnet.toString());
    // Determine the IANA code for the subnet IP version
    // Default is set to IPv4 for neutron subnets
    final Eid eid = LispAddressUtil.asIpv4PrefixEid(String.valueOf(subnet.getCidr().getValue()));
    try {
        final OdlMappingserviceService lfmdb = lispNeutronService.getMappingDbService();
        if (lfmdb == null) {
            LOG.debug("lfmdb is null!!!");
            return;
        }
        final RemoveKeyInput removeKeyInput = LispUtil.buildRemoveKeyInput(eid);
        final Future<RpcResult<Void>> result = lfmdb.removeKey(removeKeyInput);
        final Boolean isSuccessful = result.get().isSuccessful();
        if (isSuccessful) {
            LOG.debug("Neutron Subnet Deleted from MapServer : Subnet name: " + subnet.getName() + " Eid Prefix: " + subnet.getCidr() + " Key: " + subnet.getUuid());
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Deleting subnet's EID prefix from mapping service failed + Subnet: " + subnet.toString() + "Error: " + ExceptionUtils.getStackTrace(e));
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) OdlMappingserviceService(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.OdlMappingserviceService) RemoveKeyInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveKeyInput) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)14 ArrayList (java.util.ArrayList)13 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)9 FixedIps (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)9 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)8 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)7 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)7 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)6 BigInteger (java.math.BigInteger)5 ExecutionException (java.util.concurrent.ExecutionException)5 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)5 LearntVpnVipToPort (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort)5 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)5 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)5 HashSet (java.util.HashSet)4 List (java.util.List)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)4 HashMap (java.util.HashMap)3 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)3 SingleTransactionDataBroker (org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker)3