use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.
the class NeutronvpnUtils method getSubnetIpPrefixes.
protected List<IpPrefixOrAddress> getSubnetIpPrefixes(Port port) {
List<Uuid> subnetIds = getSubnetIdsFromNetworkId(port.getNetworkId());
if (subnetIds == null) {
LOG.error("Failed to get Subnet Ids for the Network {}", port.getNetworkId());
return null;
}
List<IpPrefixOrAddress> subnetIpPrefixes = new ArrayList<>();
for (Uuid subnetId : subnetIds) {
Subnet subnet = getNeutronSubnet(subnetId);
if (subnet != null) {
subnetIpPrefixes.add(new IpPrefixOrAddress(subnet.getCidr()));
}
}
return subnetIpPrefixes;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.
the class NeutronvpnUtils method getPortSecurityEnabled.
/**
* Returns port_security_enabled status with the port.
*
* @param port the port
* @return port_security_enabled status
*/
protected static boolean getPortSecurityEnabled(Port port) {
String deviceOwner = port.getDeviceOwner();
if (deviceOwner != null && deviceOwner.startsWith("network:")) {
// router interface, dhcp port and floating ip.
return false;
}
PortSecurityExtension portSecurity = port.getAugmentation(PortSecurityExtension.class);
if (portSecurity != null) {
return portSecurity.isPortSecurityEnabled();
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.
the class NeutronEvpnManager method createEVPN.
@SuppressWarnings("checkstyle:IllegalCatch")
public Future<RpcResult<CreateEVPNOutput>> createEVPN(CreateEVPNInput input) {
CreateEVPNOutputBuilder opBuilder = new CreateEVPNOutputBuilder();
SettableFuture<RpcResult<CreateEVPNOutput>> result = SettableFuture.create();
List<RpcError> errorList = new ArrayList<>();
int failurecount = 0;
int warningcount = 0;
List<String> existingRDs = neutronvpnUtils.getExistingRDs();
List<Evpn> vpns = input.getEvpn();
for (Evpn vpn : vpns) {
if (vpn.getRouteDistinguisher() == null || vpn.getImportRT() == null || vpn.getExportRT() == null) {
errorList.add(RpcResultBuilder.newWarning(RpcError.ErrorType.PROTOCOL, "invalid-input", formatAndLog(LOG::warn, "Creation of EVPN failed for VPN {} due to absence of RD/iRT/eRT input", vpn.getId().getValue())));
warningcount++;
continue;
}
VpnInstance.Type vpnInstanceType = VpnInstance.Type.L2;
if (vpn.getRouteDistinguisher().size() > 1) {
errorList.add(RpcResultBuilder.newWarning(RpcError.ErrorType.PROTOCOL, "invalid-input", formatAndLog(LOG::warn, "Creation of EVPN failed for VPN {} due to multiple RD input {}", vpn.getId().getValue(), vpn.getRouteDistinguisher())));
warningcount++;
continue;
}
if (existingRDs.contains(vpn.getRouteDistinguisher().get(0))) {
errorList.add(RpcResultBuilder.newWarning(RpcError.ErrorType.PROTOCOL, "invalid-input", formatAndLog(LOG::warn, "Creation of EVPN failed for VPN {} as another VPN with the same RD {} is already " + "configured", vpn.getId().getValue(), vpn.getRouteDistinguisher().get(0))));
warningcount++;
continue;
}
try {
neutronvpnManager.createVpn(vpn.getId(), vpn.getName(), vpn.getTenantId(), vpn.getRouteDistinguisher(), vpn.getImportRT(), vpn.getExportRT(), null, /*router-id*/
null, /*network-id*/
vpnInstanceType, 0);
} catch (Exception ex) {
errorList.add(RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, formatAndLog(LOG::error, "Creation of EVPN failed for VPN {}", vpn.getId().getValue(), ex), ex.getMessage()));
failurecount++;
}
}
if (failurecount != 0) {
result.set(RpcResultBuilder.<CreateEVPNOutput>failed().withRpcErrors(errorList).build());
} else {
List<String> errorResponseList = new ArrayList<>();
if (!errorList.isEmpty()) {
for (RpcError rpcError : errorList) {
errorResponseList.add("ErrorType: " + rpcError.getErrorType() + ", ErrorTag: " + rpcError.getTag() + ", ErrorMessage: " + rpcError.getMessage());
}
} else {
errorResponseList.add("EVPN creation successful with no errors");
}
opBuilder.setResponse(errorResponseList);
result.set(RpcResultBuilder.<CreateEVPNOutput>success().withResult(opBuilder.build()).build());
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network 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.networks.rev150712.networks.attributes.networks.Network 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);
}
Aggregations