Search in sources :

Example 6 with Reference

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Reference in project netvirt by opendaylight.

the class NeutronPortChangeListener method handleRouterInterfaceRemoved.

private void handleRouterInterfaceRemoved(Port routerPort) {
    if (routerPort.getDeviceId() != null) {
        Uuid routerId = new Uuid(routerPort.getDeviceId());
        Uuid infNetworkId = routerPort.getNetworkId();
        elanService.removeKnownL3DmacAddress(routerPort.getMacAddress().getValue(), infNetworkId.getValue());
        Uuid vpnId = neutronvpnUtils.getVpnForRouter(routerId, true);
        if (vpnId == null) {
            vpnId = routerId;
        }
        List<FixedIps> portIps = routerPort.getFixedIps();
        boolean vpnInstanceInternetIpVersionRemoved = false;
        Uuid vpnInstanceInternetUuid = null;
        for (FixedIps portIP : portIps) {
            // Internet VPN : flush InternetVPN first
            Uuid subnetId = portIP.getSubnetId();
            Subnetmap sn = neutronvpnUtils.getSubnetmap(subnetId);
            if (sn != null && sn.getInternetVpnId() != null) {
                if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToRemove(sn, sn.getInternetVpnId())) {
                    vpnInstanceInternetIpVersionRemoved = true;
                    vpnInstanceInternetUuid = sn.getInternetVpnId();
                }
                nvpnManager.updateVpnInternetForSubnet(sn, sn.getInternetVpnId(), false);
            }
        }
        /* Remove ping responder for router interfaces
             *  A router interface reference in a VPN will have to be removed before the host interface references
             * for that subnet in the VPN are removed. This is to ensure that the FIB Entry of the router interface
             *  is not the last entry to be removed for that subnet in the VPN.
             *  If router interface FIB entry is the last to be removed for a subnet in a VPN , then all the host
             *  interface references in the vpn will already have been cleared, which will cause failures in
             *  cleanup of router interface flows*/
        nvpnManager.deleteVpnInterface(routerPort.getUuid().getValue(), null, /* vpn-id */
        null);
        // update RouterInterfaces map
        WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
        boolean vpnInstanceIpVersionRemoved = false;
        IpVersionChoice vpnInstanceIpVersionToRemove = IpVersionChoice.UNDEFINED;
        for (FixedIps portIP : portIps) {
            Subnetmap sn = neutronvpnUtils.getSubnetmap(portIP.getSubnetId());
            // router Port have either IPv4 or IPv6, never both
            if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToRemove(sn, vpnId)) {
                vpnInstanceIpVersionRemoved = true;
                vpnInstanceIpVersionToRemove = neutronvpnUtils.getIpVersionFromString(sn.getSubnetIp());
            }
            String ipValue = String.valueOf(portIP.getIpAddress().getValue());
            neutronvpnUtils.removeVpnPortFixedIpToPort(vpnId.getValue(), ipValue, wrtConfigTxn);
            // NOTE:  Please donot change the order of calls to removeSubnetFromVpn and
            // and updateSubnetNodeWithFixedIP
            nvpnManager.removeSubnetFromVpn(vpnId, portIP.getSubnetId(), sn != null ? sn.getInternetVpnId() : null);
            nvpnManager.updateSubnetNodeWithFixedIp(portIP.getSubnetId(), null, null, null, null, null);
        }
        nvpnManager.removeFromNeutronRouterInterfacesMap(routerId, routerPort.getUuid().getValue());
        deleteElanInterface(routerPort.getUuid().getValue(), wrtConfigTxn);
        deleteOfPortInterface(routerPort, wrtConfigTxn);
        wrtConfigTxn.submit();
        nvpnNatManager.handleSubnetsForExternalRouter(routerId);
        if (vpnInstanceIpVersionRemoved) {
            neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), vpnInstanceIpVersionToRemove, false);
        }
        if (vpnInstanceInternetIpVersionRemoved) {
            neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnInstanceInternetUuid.getValue(), IpVersionChoice.IPV6, false);
            neutronvpnUtils.updateVpnInstanceWithFallback(vpnInstanceInternetUuid.getValue(), false);
        }
    }
}
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) 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) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)

Example 7 with Reference

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Reference in project netvirt by opendaylight.

the class QosNeutronUtils method getBridgeRefEntryFromOperDS.

@Nullable
private OvsdbBridgeRef getBridgeRefEntryFromOperDS(BigInteger dpId) {
    BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(dpId);
    InstanceIdentifier<BridgeRefEntry> bridgeRefEntryIid = getBridgeRefEntryIdentifier(bridgeRefEntryKey);
    BridgeRefEntry bridgeRefEntry = getBridgeRefEntryFromOperDS(bridgeRefEntryIid);
    if (bridgeRefEntry == null) {
        // bridge ref entry will be null if the bridge is disconnected from controller.
        // In that case, fetch bridge reference from bridge interface entry config DS
        BridgeEntry bridgeEntry = getBridgeEntryFromConfigDS(dpId);
        if (bridgeEntry == null) {
            return null;
        }
        return bridgeEntry.getBridgeReference();
    }
    return bridgeRefEntry.getBridgeReference();
}
Also used : BridgeRefEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntry) BridgeEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.BridgeEntry) BridgeRefEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntryKey) Nullable(javax.annotation.Nullable)

Example 8 with Reference

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Reference in project bgpcep by opendaylight.

the class CommunityUtil method valueOf.

/**
 * Creates a Community from its String representation.
 *
 * @param refCache reference cache to use
 * @param string String representation of a community
 * @return new Community
 */
public static Community valueOf(final ReferenceCache refCache, final String string) {
    final String[] parts = string.split(":", 2);
    final CommunitiesBuilder builder = new CommunitiesBuilder();
    builder.setAsNumber(refCache.getSharedReference(new AsNumber(Long.valueOf(parts[0]))));
    builder.setSemantics(refCache.getSharedReference(Integer.valueOf(parts[1])));
    return refCache.getSharedReference(builder.build());
}
Also used : CommunitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.CommunitiesBuilder) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)

Example 9 with Reference

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Reference in project controller by opendaylight.

the class RoutedServiceIT method createNodeRef.

/**
 * Returns node reference from string which represents path
 *
 * @param string
 *            string with key(path)
 * @return instance identifier to {@link UnorderedList}
 */
private static InstanceIdentifier<UnorderedList> createNodeRef(final String string) {
    final UnorderedListKey key = new UnorderedListKey(string);
    final InstanceIdentifier<UnorderedList> path = InstanceIdentifier.builder(Lists.class).child(UnorderedContainer.class).child(UnorderedList.class, key).build();
    return path;
}
Also used : Lists(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists) UnorderedList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList) UnorderedListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListKey)

Example 10 with Reference

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Reference in project bgpcep by opendaylight.

the class SetCommunityHandler method setComm.

private Attributes setComm(final Attributes attributes, final SetCommunityMethod setCommunityMethod, final BgpSetCommunityOptionType options) {
    if (setCommunityMethod instanceof Inline) {
        final Inline inline = (Inline) setCommunityMethod;
        final List<Communities> list = inline.getCommunities().stream().map(ge -> new CommunitiesBuilder().setAsNumber(ge.getAsNumber()).setSemantics(ge.getSemantics()).build()).collect(Collectors.toList());
        return inlineSetComm(attributes, list, options);
    }
    return referenceSetComm(attributes, ((Reference) setCommunityMethod).getCommunitySetRef(), options);
}
Also used : Communities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.Communities) BGPRouteEntryExportParameters(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters) SetCommunity(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.SetCommunity) BgpActionPolicy(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.action.BgpActionPolicy) AbstractCommunityHandler(org.opendaylight.protocol.bgp.openconfig.routing.policy.statement.AbstractCommunityHandler) BgpSetCommunityOptionType(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.BgpSetCommunityOptionType) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) ArrayList(java.util.ArrayList) SetCommunityMethod(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.community.SetCommunityMethod) List(java.util.List) Inline(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.community.set.community.method.Inline) BGPRouteEntryImportParameters(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters) RouteEntryBaseAttributes(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes) Reference(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.community.set.community.method.Reference) CommunitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.CommunitiesBuilder) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) CommunitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.CommunitiesBuilder) Communities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.Communities) Inline(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.community.set.community.method.Inline)

Aggregations

ArrayList (java.util.ArrayList)8 Test (org.junit.Test)6 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)6 Statement (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement)6 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)6 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)4 BigInteger (java.math.BigInteger)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Nullable (javax.annotation.Nullable)3 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)3 CommunitiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.CommunitiesBuilder)3 StringUtils (org.apache.commons.lang3.StringUtils)2 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)2 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)2 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)2 RouteEntryBaseAttributes (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes)2 BgpActionPolicy (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.action.BgpActionPolicy)2 BGPRouteEntryExportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)2 BGPRouteEntryImportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters)2