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;
}
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;
}
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;
}
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;
}
Aggregations