Search in sources :

Example 1 with IpVersionBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpVersionBase in project netvirt by opendaylight.

the class DhcpServiceUtils method isIpv4Subnet.

public static boolean isIpv4Subnet(DataBroker broker, Uuid subnetUuid) {
    final SubnetKey subnetkey = new SubnetKey(subnetUuid);
    final InstanceIdentifier<Subnet> subnetidentifier = InstanceIdentifier.create(Neutron.class).child(Subnets.class).child(Subnet.class, subnetkey);
    final Optional<Subnet> subnet;
    try {
        subnet = SingleTransactionDataBroker.syncReadOptional(broker, LogicalDatastoreType.CONFIGURATION, subnetidentifier);
    } catch (ExecutionException | InterruptedException e) {
        LOG.error("isIpv4Subnet: Exception while reading Subnet DS for the Subnet {}", subnetUuid.getValue(), e);
        return false;
    }
    if (subnet.isPresent()) {
        Class<? extends IpVersionBase> ipVersionBase = subnet.get().getIpVersion();
        return IpVersionV4.class.equals(ipVersionBase);
    }
    return false;
}
Also used : Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets) SubnetKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetKey) Subnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with IpVersionBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpVersionBase in project netvirt by opendaylight.

the class VpnUtil method getVpnSubnetGatewayIp.

public static Optional<String> getVpnSubnetGatewayIp(DataBroker dataBroker, final Uuid subnetUuid) {
    Optional<String> gwIpAddress = Optional.absent();
    final SubnetKey subnetkey = new SubnetKey(subnetUuid);
    final InstanceIdentifier<Subnet> subnetidentifier = InstanceIdentifier.create(Neutron.class).child(Subnets.class).child(Subnet.class, subnetkey);
    final Optional<Subnet> subnet = read(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetidentifier);
    if (subnet.isPresent()) {
        Class<? extends IpVersionBase> ipVersionBase = subnet.get().getIpVersion();
        if (ipVersionBase.equals(IpVersionV4.class)) {
            LOG.trace("getVpnSubnetGatewayIp: Obtained subnet {} for vpn interface", subnet.get().getUuid().getValue());
            IpAddress gwIp = subnet.get().getGatewayIp();
            if (gwIp != null && gwIp.getIpv4Address() != null) {
                gwIpAddress = Optional.of(gwIp.getIpv4Address().getValue());
            }
        }
    }
    return gwIpAddress;
}
Also used : ExternalSubnets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalSubnets) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets) SubnetKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetKey) 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)

Example 3 with IpVersionBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpVersionBase in project netvirt by opendaylight.

the class VpnUtil method getVpnSubnetGatewayIp.

public Optional<String> getVpnSubnetGatewayIp(final Uuid subnetUuid) {
    Optional<String> gwIpAddress = Optional.empty();
    final SubnetKey subnetkey = new SubnetKey(subnetUuid);
    final InstanceIdentifier<Subnet> subnetidentifier = InstanceIdentifier.create(Neutron.class).child(Subnets.class).child(Subnet.class, subnetkey);
    final Optional<Subnet> subnet = read(LogicalDatastoreType.CONFIGURATION, subnetidentifier);
    if (subnet.isPresent()) {
        Class<? extends IpVersionBase> ipVersionBase = subnet.get().getIpVersion();
        if (IpVersionV4.class.equals(ipVersionBase)) {
            Subnetmap subnetmap = getSubnetmapFromItsUuid(subnetUuid);
            if (subnetmap != null && subnetmap.getRouterInterfaceFixedIp() != null) {
                LOG.trace("getVpnSubnetGatewayIp: Obtained subnetMap {} for vpn interface", subnetmap.getId().getValue());
                gwIpAddress = Optional.of(subnetmap.getRouterInterfaceFixedIp());
            } else {
                // For direct L3VPN to network association (no router) continue to use subnet-gateway IP
                IpAddress gwIp = subnet.get().getGatewayIp();
                if (gwIp != null && gwIp.getIpv4Address() != null) {
                    gwIpAddress = Optional.of(gwIp.getIpv4Address().getValue());
                }
            }
            LOG.trace("getVpnSubnetGatewayIp: Obtained subnet-gw ip {} for vpn interface", gwIpAddress.get());
        }
    }
    return gwIpAddress;
}
Also used : ExternalSubnets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalSubnets) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets) AssociatedSubnetKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnets.associated.to.route.targets.route.target.AssociatedSubnetKey) SubnetKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetKey) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) AssociatedSubnet(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnets.associated.to.route.targets.route.target.AssociatedSubnet) Subnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet)

Example 4 with IpVersionBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpVersionBase in project netvirt by opendaylight.

the class NeutronvpnUtils method getSubnetInfo.

@Nullable
protected List<SubnetInfo> getSubnetInfo(Port port) {
    Map<FixedIpsKey, FixedIps> keyFixedIpsMap = port.getFixedIps();
    if (keyFixedIpsMap == null) {
        LOG.error("Failed to get Fixed IPs for the port {}", port.getName());
        return null;
    }
    List<SubnetInfo> subnetInfoList = new ArrayList<>();
    for (FixedIps portFixedIp : keyFixedIpsMap.values()) {
        Uuid subnetId = portFixedIp.getSubnetId();
        Subnet subnet = getNeutronSubnet(subnetId);
        if (subnet != null) {
            Class<? extends IpVersionBase> ipVersion = NeutronSecurityGroupConstants.IP_VERSION_MAP.get(subnet.getIpVersion());
            Class<? extends Dhcpv6Base> raMode = subnet.getIpv6RaMode() == null ? null : NeutronSecurityGroupConstants.RA_MODE_MAP.get(subnet.getIpv6RaMode());
            SubnetInfo subnetInfo = new SubnetInfoBuilder().withKey(new SubnetInfoKey(subnetId)).setIpVersion(ipVersion).setIpPrefix(new IpPrefixOrAddress(subnet.getCidr())).setIpv6RaMode(raMode).setGatewayIp(subnet.getGatewayIp()).build();
            subnetInfoList.add(subnetInfo);
        }
    }
    return subnetInfoList;
}
Also used : IpPrefixOrAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress) ArrayList(java.util.ArrayList) SubnetInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfoKey) SubnetInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfoBuilder) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) FixedIpsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) Subnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet) SubnetInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfo) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

Subnet (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet)4 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets)3 SubnetKey (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetKey)3 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 ExternalSubnets (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalSubnets)2 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)1 IpPrefixOrAddress (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress)1 SubnetInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfo)1 SubnetInfoBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfoBuilder)1 SubnetInfoKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfoKey)1 AssociatedSubnet (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnets.associated.to.route.targets.route.target.AssociatedSubnet)1 AssociatedSubnetKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnets.associated.to.route.targets.route.target.AssociatedSubnetKey)1 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)1 FixedIps (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)1 FixedIpsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey)1