Search in sources :

Example 26 with Networks

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Networks in project netvirt by opendaylight.

the class NatUtil method checkForRoutersWithSameExtNetAndNaptSwitch.

public static boolean checkForRoutersWithSameExtNetAndNaptSwitch(DataBroker broker, Uuid networkId, String routerName, BigInteger dpnId) {
    InstanceIdentifier<Networks> id = buildNetworkIdentifier(networkId);
    Optional<Networks> networkData = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, id);
    if (networkData != null && networkData.isPresent()) {
        List<Uuid> routerUuidList = networkData.get().getRouterIds();
        if (routerUuidList != null && !routerUuidList.isEmpty()) {
            for (Uuid routerUuid : routerUuidList) {
                String sharedRouterName = routerUuid.getValue();
                if (!routerName.equals(sharedRouterName)) {
                    BigInteger swtichDpnId = NatUtil.getPrimaryNaptfromRouterName(broker, sharedRouterName);
                    if (swtichDpnId == null) {
                        continue;
                    } else if (swtichDpnId.equals(dpnId)) {
                        LOG.debug("checkForRoutersWithSameExtNetAndNaptSwitch: external-network {} is " + "associated with other active router {} on NAPT switch {}", networkId, sharedRouterName, swtichDpnId);
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : Networks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.Networks) ExternalNetworks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) BigInteger(java.math.BigInteger)

Example 27 with Networks

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Networks in project netvirt by opendaylight.

the class FloatingIPListener method getVpnId.

private long getVpnId(Uuid extNwId, Uuid floatingIpExternalId) {
    Uuid subnetId = NatUtil.getFloatingIpPortSubnetIdFromFloatingIpId(dataBroker, floatingIpExternalId);
    if (subnetId != null) {
        long vpnId = NatUtil.getVpnId(dataBroker, subnetId.getValue());
        if (vpnId != NatConstants.INVALID_ID) {
            LOG.debug("getVpnId : Got vpnId {} for floatingIpExternalId {}", vpnId, floatingIpExternalId);
            return vpnId;
        }
    }
    InstanceIdentifier<Networks> nwId = InstanceIdentifier.builder(ExternalNetworks.class).child(Networks.class, new NetworksKey(extNwId)).build();
    Optional<Networks> nw = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, nwId);
    if (!nw.isPresent()) {
        LOG.error("getVpnId : Unable to read external network for {}", extNwId);
        return NatConstants.INVALID_ID;
    }
    Uuid vpnUuid = nw.get().getVpnid();
    if (vpnUuid == null) {
        LOG.error("getVpnId : Unable to read vpn from External network: {}", extNwId);
        return NatConstants.INVALID_ID;
    }
    // Get the id using the VPN UUID (also vpn instance name)
    return NatUtil.getVpnId(dataBroker, vpnUuid.getValue());
}
Also used : Networks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.Networks) ExternalNetworks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks) NetworksKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksKey) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Example 28 with Networks

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Networks in project netvirt by opendaylight.

the class ExternalNetworksChangeListener method remove.

@Override
protected void remove(InstanceIdentifier<Networks> identifier, Networks networks) {
    if (identifier == null || networks == null || networks.getRouterIds().isEmpty()) {
        LOG.warn("remove : returning without processing since networks/identifier is null: " + "identifier: {}, networks: {}", identifier, networks);
        return;
    }
    for (Uuid routerId : networks.getRouterIds()) {
        String routerName = routerId.toString();
        InstanceIdentifier<RouterToNaptSwitch> routerToNaptSwitchInstanceIdentifier = NatUtil.buildNaptSwitchIdentifier(routerName);
        MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.OPERATIONAL, routerToNaptSwitchInstanceIdentifier);
        LOG.debug("remove : successful deletion of data in napt-switches container");
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RouterToNaptSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch)

Example 29 with Networks

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Networks in project netvirt by opendaylight.

the class NaptSwitchHA method getRouterIdsForExtNetwork.

@Nonnull
private List<String> getRouterIdsForExtNetwork(Uuid extNetworkId) {
    List<String> routerUuidsAsString = new ArrayList<>();
    InstanceIdentifier<Networks> extNetwork = InstanceIdentifier.builder(ExternalNetworks.class).child(Networks.class, new NetworksKey(extNetworkId)).build();
    Optional<Networks> extNetworkData = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, extNetwork);
    if (extNetworkData.isPresent()) {
        List<Uuid> routerUuids = extNetworkData.get().getRouterIds();
        if (routerUuids != null) {
            for (Uuid routerUuid : routerUuids) {
                routerUuidsAsString.add(routerUuid.getValue());
            }
        }
    }
    return routerUuidsAsString;
}
Also used : Networks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.Networks) ExternalNetworks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks) NetworksKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksKey) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) Nonnull(javax.annotation.Nonnull)

Example 30 with Networks

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Networks in project netvirt by opendaylight.

the class BgpManagerTestImpl method addPrefix.

public void addPrefix(String rd, String macAddress, String pfx, List<String> nhList, VrfEntry.EncapType encapType, long lbl, long l3vni, long l2vni, String gatewayMac) throws TransactionCommitFailedException {
    for (String nh : nhList) {
        Ipv4Address nexthop = nh != null ? new Ipv4Address(nh) : null;
        Long label = lbl;
        InstanceIdentifier<Networks> iid = InstanceIdentifier.builder(Bgp.class).child(Networks.class, new NetworksKey(pfx, rd)).build();
        NetworksBuilder networksBuilder = new NetworksBuilder().setRd(rd).setPrefixLen(pfx).setNexthop(nexthop).setLabel(label).setEthtag(0L);
        buildVpnEncapSpecificInfo(networksBuilder, encapType, label, l3vni, l2vni, macAddress, gatewayMac);
        singleTxdataBroker.syncWrite(LogicalDatastoreType.CONFIGURATION, iid, networksBuilder.build());
    }
}
Also used : Networks(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Networks) NetworksKey(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.NetworksKey) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) NetworksBuilder(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.NetworksBuilder)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)29 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)12 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)11 ExternalNetworks (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks)11 Networks (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.Networks)11 NetworksKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksKey)10 ArrayList (java.util.ArrayList)9 BigInteger (java.math.BigInteger)7 NetworksBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksBuilder)6 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)6 Nonnull (javax.annotation.Nonnull)5 Networks (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Networks)5 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 HashSet (java.util.HashSet)3 ExecutionException (java.util.concurrent.ExecutionException)3 IpVersionChoice (org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)3 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 InternalToExternalPortMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap)3 VpnMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap)3