Search in sources :

Example 11 with Neutron

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

the class DhcpUCastMacListener method add.

@Override
protected void add(InstanceIdentifier<LocalUcastMacs> identifier, LocalUcastMacs add) {
    NodeId torNodeId = identifier.firstKeyOf(Node.class).getNodeId();
    InstanceIdentifier<LogicalSwitches> logicalSwitchRef = (InstanceIdentifier<LogicalSwitches>) add.getLogicalSwitchRef().getValue();
    Optional<LogicalSwitches> logicalSwitchOptional = MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL, logicalSwitchRef);
    if (!logicalSwitchOptional.isPresent()) {
        LOG.error("Logical Switch ref doesn't have data {}", logicalSwitchRef);
        return;
    }
    LogicalSwitches logicalSwitch = logicalSwitchOptional.get();
    String elanInstanceName = logicalSwitch.getHwvtepNodeName().getValue();
    String macAddress = add.getMacEntryKey().getValue();
    BigInteger vni = new BigInteger(logicalSwitch.getTunnelKey());
    Port port = dhcpExternalTunnelManager.readVniMacToPortCache(vni, macAddress);
    if (port == null) {
        LOG.trace("No neutron port created for macAddress {}, tunnelKey {}", macAddress, vni);
        return;
    }
    L2GatewayDevice device = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanInstanceName, torNodeId.getValue());
    if (device == null) {
        LOG.error("Logical Switch Device with name {} is not present in L2GWCONN cache", elanInstanceName);
        return;
    }
    IpAddress tunnelIp = device.getTunnelIp();
    Subnet subnet = dhcpManager.getNeutronSubnet(port);
    if (null != subnet && !subnet.isEnableDhcp()) {
        dhcpExternalTunnelManager.updateExistingVMTunnelIPCache(tunnelIp, elanInstanceName, macAddress);
        LOG.warn("DhcpUCastMacListener add: flag for the subnetId {} is False so Table 18 entries are not added", subnet.getUuid());
        return;
    }
    BigInteger designatedDpnId = dhcpExternalTunnelManager.readDesignatedSwitchesForExternalTunnel(tunnelIp, elanInstanceName);
    if (designatedDpnId == null || designatedDpnId.equals(DhcpMConstants.INVALID_DPID)) {
        LOG.trace("Unable to install flows for macAddress {}. TunnelIp {}, elanInstanceName {}, designatedDpn {} ", macAddress, tunnelIp, elanInstanceName, designatedDpnId);
        dhcpExternalTunnelManager.updateLocalCache(tunnelIp, elanInstanceName, macAddress);
        return;
    }
    dhcpExternalTunnelManager.installDhcpFlowsForVms(tunnelIp, elanInstanceName, DhcpServiceUtils.getListOfDpns(broker), designatedDpnId, macAddress);
}
Also used : LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Subnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 12 with Neutron

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

the class NeutronvpnUtils method createVpnPortFixedIpToPort.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
protected void createVpnPortFixedIpToPort(String vpnName, String fixedIp, String portName, String macAddress, boolean isSubnetIp, WriteTransaction writeConfigTxn) {
    InstanceIdentifier<VpnPortipToPort> id = NeutronvpnUtils.buildVpnPortipToPortIdentifier(vpnName, fixedIp);
    VpnPortipToPortBuilder builder = new VpnPortipToPortBuilder().setKey(new VpnPortipToPortKey(fixedIp, vpnName)).setVpnName(vpnName).setPortFixedip(fixedIp).setPortName(portName).setMacAddress(macAddress).setSubnetIp(isSubnetIp);
    try {
        if (writeConfigTxn != null) {
            writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION, id, builder.build());
        } else {
            MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, id, builder.build());
        }
        LOG.trace("Neutron port with fixedIp: {}, vpn {}, interface {}, mac {}, isSubnetIp {} added to " + "VpnPortipToPort DS", fixedIp, vpnName, portName, macAddress, isSubnetIp);
    } catch (Exception e) {
        LOG.error("Failure while creating VPNPortFixedIpToPort map for vpn {} - fixedIP {}", vpnName, fixedIp, e);
    }
}
Also used : VpnPortipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort) VpnPortipToPortKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPortKey) VpnPortipToPortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPortBuilder) UnknownHostException(java.net.UnknownHostException) ExecutionException(java.util.concurrent.ExecutionException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)

Example 13 with Neutron

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

the class NeutronSubnetChangeListener method remove.

@Override
protected void remove(InstanceIdentifier<Subnet> identifier, Subnet input) {
    LOG.trace("Removing subnet : key: {}, value={}", identifier, input);
    Uuid networkId = input.getNetworkId();
    Uuid subnetId = input.getUuid();
    Network network = neutronvpnUtils.getNeutronNetwork(networkId);
    if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) {
        LOG.warn("neutron vpn received a subnet remove() for a network without a provider extension augmentation " + "or with an unsupported network type for the subnet {} which is part of network {}", subnetId.getValue(), network);
        return;
    }
    handleNeutronSubnetDeleted(subnetId, networkId);
    externalSubnetHandler.handleExternalSubnetRemoved(network, subnetId);
    neutronvpnUtils.removeFromSubnetCache(input);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)

Example 14 with Neutron

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

the class NeutronSubnetChangeListener method add.

@Override
protected void add(InstanceIdentifier<Subnet> identifier, Subnet input) {
    LOG.trace("Adding Subnet : key: {}, value={}", identifier, input);
    Uuid networkId = input.getNetworkId();
    Uuid subnetId = input.getUuid();
    Network network = neutronvpnUtils.getNeutronNetwork(networkId);
    if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) {
        LOG.warn("neutron vpn received a subnet add() for a network without a provider extension augmentation " + "or with an unsupported network type for the subnet {} which is part of network {}", subnetId.getValue(), network);
        return;
    }
    neutronvpnUtils.addToSubnetCache(input);
    handleNeutronSubnetCreated(input, network);
    externalSubnetHandler.handleExternalSubnetAdded(network, subnetId, null);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)

Example 15 with Neutron

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

the class NeutronTrunkChangeListener method deleteSubPortInterface.

private void deleteSubPortInterface(SubPorts subPort) {
    String portName = subPort.getPortId().getValue();
    InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(subPort.getPortId().getValue());
    jobCoordinator.enqueueJob("PORT- " + portName, () -> {
        Interface iface = ifMgr.getInterfaceInfoFromConfigDataStore(portName);
        List<ListenableFuture<Void>> futures = new ArrayList<>();
        if (iface == null) {
            LOG.warn("Interface not present for SubPort {}", subPort);
            return futures;
        }
        /*
             * We'll reset interface back to way it was? Can IFM handle parentRef delete?
             */
        InterfaceBuilder interfaceBuilder = new InterfaceBuilder(iface);
        // Reset augmentations
        interfaceBuilder.removeAugmentation(IfL2vlan.class).removeAugmentation(ParentRefs.class).removeAugmentation(SplitHorizon.class);
        IfL2vlan ifL2vlan = new IfL2vlanBuilder().setL2vlanMode(IfL2vlan.L2vlanMode.Trunk).build();
        interfaceBuilder.addAugmentation(IfL2vlan.class, ifL2vlan);
        iface = interfaceBuilder.build();
        /*
             * There is no means to do an update to remove elements from a node.
             * Our solution is to get existing iface, remove parentRef and VlanId,
             * and do a put to replace existing entry. This works out better as put
             * has better performance than merge.
             * Only drawback is any in-flight changes might be lost, but that is a corner case
             * and this being subport delete path, don't expect any significant changes to
             * corresponding Neutron Port. Deletion of NeutronPort should follow soon enough.
             */
        WriteTransaction txn = dataBroker.newWriteOnlyTransaction();
        txn.put(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, iface);
        LOG.trace("Resetting trunk member interface {}", iface);
        futures.add(txn.submit());
        return futures;
    });
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) IfL2vlanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

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