Search in sources :

Example 1 with ExternalGatewayInfo

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.ExternalGatewayInfo in project netvirt by opendaylight.

the class NeutronvpnNatManager method externalFixedIpsChanged.

private boolean externalFixedIpsChanged(Router orig, Router update) {
    ExternalGatewayInfo origExtGw = null;
    ExternalGatewayInfo newExtGw = null;
    if (orig != null && orig.getExternalGatewayInfo() != null) {
        origExtGw = orig.getExternalGatewayInfo();
    }
    if (update != null && update.getExternalGatewayInfo() != null) {
        newExtGw = update.getExternalGatewayInfo();
    }
    if (origExtGw == null && newExtGw != null && newExtGw.getExternalFixedIps() != null && !newExtGw.getExternalFixedIps().isEmpty()) {
        return true;
    }
    if (newExtGw == null && origExtGw != null && origExtGw.getExternalFixedIps() != null && !origExtGw.getExternalFixedIps().isEmpty()) {
        return true;
    }
    if (origExtGw != null && newExtGw != null) {
        if (origExtGw.getExternalFixedIps() != null) {
            if (!origExtGw.getExternalFixedIps().isEmpty()) {
                if (newExtGw.getExternalFixedIps() != null && !newExtGw.getExternalFixedIps().isEmpty()) {
                    List<ExternalFixedIps> origExtFixedIps = origExtGw.getExternalFixedIps();
                    HashSet<String> origFixedIpSet = new HashSet<>();
                    for (ExternalFixedIps fixedIps : origExtFixedIps) {
                        origFixedIpSet.add(fixedIps.getIpAddress().getIpv4Address().getValue());
                    }
                    List<ExternalFixedIps> newExtFixedIps = newExtGw.getExternalFixedIps();
                    HashSet<String> updFixedIpSet = new HashSet<>();
                    for (ExternalFixedIps fixedIps : newExtFixedIps) {
                        updFixedIpSet.add(fixedIps.getIpAddress().getIpv4Address().getValue());
                    }
                    // returns true if external subnets have changed
                    return !origFixedIpSet.equals(updFixedIpSet) ? true : false;
                }
                return true;
            } else if (newExtGw.getExternalFixedIps() != null && !newExtGw.getExternalFixedIps().isEmpty()) {
                return true;
            }
        } else if (newExtGw.getExternalFixedIps() != null && !newExtGw.getExternalFixedIps().isEmpty()) {
            return true;
        }
    }
    return false;
}
Also used : ExternalFixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIps) ExternalGatewayInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.ExternalGatewayInfo) HashSet(java.util.HashSet)

Example 2 with ExternalGatewayInfo

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.ExternalGatewayInfo in project netvirt by opendaylight.

the class NeutronSubnetGwMacResolver method getExternalInterface.

private String getExternalInterface(Router router) {
    ExternalGatewayInfo extGatewayInfo = router.getExternalGatewayInfo();
    String routerName = router.getUuid().getValue();
    if (extGatewayInfo == null) {
        LOG.warn("External GW info missing for router {}", routerName);
        return null;
    }
    Uuid extNetworkId = extGatewayInfo.getExternalNetworkId();
    if (extNetworkId == null) {
        LOG.warn("External network id missing for router {}", routerName);
        return null;
    }
    BigInteger primarySwitch = cswitchProvider.getPrimarySwitchForRouter(routerName);
    if (primarySwitch == null || BigInteger.ZERO.equals(primarySwitch)) {
        LOG.warn("Primary switch has not been allocated for router {}", routerName);
        return null;
    }
    return elanService.getExternalElanInterface(extNetworkId.getValue(), primarySwitch);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ExternalGatewayInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.ExternalGatewayInfo) BigInteger(java.math.BigInteger)

Example 3 with ExternalGatewayInfo

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.ExternalGatewayInfo in project netvirt by opendaylight.

the class NeutronvpnNatManager method snatSettingChanged.

private boolean snatSettingChanged(Router orig, Router update) {
    ExternalGatewayInfo origExtGw = null;
    ExternalGatewayInfo newExtGw = null;
    if (orig != null && orig.getExternalGatewayInfo() != null) {
        origExtGw = orig.getExternalGatewayInfo();
    }
    if (update != null && update.getExternalGatewayInfo() != null) {
        newExtGw = update.getExternalGatewayInfo();
    }
    if (origExtGw == null) {
        if (newExtGw != null) {
            return true;
        }
    } else if (newExtGw == null || !Objects.equals(origExtGw.isEnableSnat(), newExtGw.isEnableSnat())) {
        return true;
    }
    return false;
}
Also used : ExternalGatewayInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.ExternalGatewayInfo)

Example 4 with ExternalGatewayInfo

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.ExternalGatewayInfo in project netvirt by opendaylight.

the class NeutronvpnUtils method getPrivateSubnetsToExport.

/**
 * Get a list of Private Subnetmap Ids from router to export then its prefixes in Internet VPN.
 * @param extNet Provider Network, which has a port attached as external network gateway to router
 * @return a list of Private Subnetmap Ids of the router with external network gateway
 */
@Nonnull
public List<Uuid> getPrivateSubnetsToExport(@Nonnull Network extNet) {
    List<Uuid> subList = new ArrayList<>();
    Uuid extNetVpnId = getVpnForNetwork(extNet.getUuid());
    if (extNetVpnId == null) {
        return subList;
    }
    Router router = getNeutronRouter(getRouterforVpn(extNetVpnId));
    ExternalGatewayInfo info = router.getExternalGatewayInfo();
    if (info == null) {
        LOG.error("getPrivateSubnetsToExport: can not get info about external gateway for router {}", router.getUuid().getValue());
        return subList;
    }
    // check that router really has given provider network as its external gateway port
    if (!extNet.getUuid().equals(info.getExternalNetworkId())) {
        LOG.error("getPrivateSubnetsToExport: router {} is not attached to given provider network {}", router.getUuid().getValue(), extNet.getUuid().getValue());
        return subList;
    }
    return getSubnetsforVpn(router.getUuid());
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) Router(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router) ExternalGatewayInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.ExternalGatewayInfo) Nonnull(javax.annotation.Nonnull)

Aggregations

ExternalGatewayInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.ExternalGatewayInfo)4 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)2 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Nonnull (javax.annotation.Nonnull)1 Router (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router)1 ExternalFixedIps (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIps)1