Search in sources :

Example 1 with IpVersionBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.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 = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, subnetidentifier);
    if (subnet.isPresent()) {
        Class<? extends IpVersionBase> ipVersionBase = subnet.get().getIpVersion();
        if (ipVersionBase.equals(IpVersionV4.class)) {
            return true;
        }
    }
    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)

Example 2 with IpVersionBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.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)

Aggregations

Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets)2 Subnet (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet)2 SubnetKey (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetKey)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 ExternalSubnets (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalSubnets)1