use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.
the class NeutronvpnUtils method getIPPrefixFromPort.
// TODO Clean up the exception handling and the console output
@SuppressWarnings({ "checkstyle:IllegalCatch", "checkstyle:RegexpSinglelineJava" })
protected Short getIPPrefixFromPort(Port port) {
try {
Uuid subnetUUID = port.getFixedIps().get(0).getSubnetId();
SubnetKey subnetkey = new SubnetKey(subnetUUID);
InstanceIdentifier<Subnet> subnetidentifier = InstanceIdentifier.create(Neutron.class).child(Subnets.class).child(Subnet.class, subnetkey);
Optional<Subnet> subnet = read(LogicalDatastoreType.CONFIGURATION, subnetidentifier);
if (subnet.isPresent()) {
String cidr = String.valueOf(subnet.get().getCidr().getValue());
// Extract the prefix length from cidr
String[] parts = cidr.split("/");
if (parts.length == 2) {
return Short.valueOf(parts[1]);
} else {
LOG.trace("Could not retrieve prefix from subnet CIDR");
}
} else {
LOG.trace("Unable to read on subnet datastore");
}
} catch (Exception e) {
LOG.error("Failed to retrieve IP prefix from port for port {}", port.getUuid().getValue(), e);
}
LOG.error("Failed for port {}", port.getUuid().getValue());
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.
the class NeutronvpnUtils method getNeutronSubnet.
protected Subnet getNeutronSubnet(Uuid subnetId) {
Subnet subnet = subnetMap.get(subnetId);
if (subnet != null) {
return subnet;
}
InstanceIdentifier<Subnet> inst = InstanceIdentifier.create(Neutron.class).child(Subnets.class).child(Subnet.class, new SubnetKey(subnetId));
Optional<Subnet> sn = read(LogicalDatastoreType.CONFIGURATION, inst);
if (sn.isPresent()) {
subnet = sn.get();
}
return subnet;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.
the class NeutronSubnetChangeListener method handleNeutronSubnetCreated.
private void handleNeutronSubnetCreated(Subnet subnet, Network network) {
Uuid networkId = network.getUuid();
Uuid subnetId = subnet.getUuid();
ProviderTypes providerType = NeutronvpnUtils.getProviderNetworkType(network);
String segmentationId = NeutronvpnUtils.getSegmentationIdFromNeutronNetwork(network);
nvpnManager.createSubnetmapNode(subnetId, String.valueOf(subnet.getCidr().getValue()), subnet.getTenantId(), networkId, providerType != null ? NetworkAttributes.NetworkType.valueOf(providerType.getName()) : null, segmentationId != null ? Long.parseLong(segmentationId) : 0L);
createSubnetToNetworkMapping(subnetId, networkId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.
the class NeutronSubnetChangeListener method remove.
@Override
protected void remove(InstanceIdentifier<Subnet> identifier, Subnet input) {
LOG.trace("Removing subnet : key: {}, value={}", identifier, input);
Uuid networkId = input.getNetworkId();
Uuid subnetId = input.getUuid();
Network network = neutronvpnUtils.getNeutronNetwork(networkId);
if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) {
LOG.warn("neutron vpn received a subnet remove() for a network without a provider extension augmentation " + "or with an unsupported network type for the subnet {} which is part of network {}", subnetId.getValue(), network);
return;
}
handleNeutronSubnetDeleted(subnetId, networkId);
externalSubnetHandler.handleExternalSubnetRemoved(network, subnetId);
neutronvpnUtils.removeFromSubnetCache(input);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.
the class NeutronSubnetChangeListener method add.
@Override
protected void add(InstanceIdentifier<Subnet> identifier, Subnet input) {
LOG.trace("Adding Subnet : key: {}, value={}", identifier, input);
Uuid networkId = input.getNetworkId();
Uuid subnetId = input.getUuid();
Network network = neutronvpnUtils.getNeutronNetwork(networkId);
if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) {
LOG.warn("neutron vpn received a subnet add() for a network without a provider extension augmentation " + "or with an unsupported network type for the subnet {} which is part of network {}", subnetId.getValue(), network);
return;
}
neutronvpnUtils.addToSubnetCache(input);
handleNeutronSubnetCreated(input, network);
externalSubnetHandler.handleExternalSubnetAdded(network, subnetId, null);
}
Aggregations