Search in sources :

Example 76 with Router

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router in project netvirt by opendaylight.

the class NeutronvpnUtils method getNeutronRouter.

protected Router getNeutronRouter(Uuid routerId) {
    Router router = routerMap.get(routerId);
    if (router != null) {
        return router;
    }
    InstanceIdentifier<Router> inst = InstanceIdentifier.create(Neutron.class).child(Routers.class).child(Router.class, new RouterKey(routerId));
    Optional<Router> rtr = read(LogicalDatastoreType.CONFIGURATION, inst);
    if (rtr.isPresent()) {
        router = rtr.get();
    }
    return router;
}
Also used : ExtRouters(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExtRouters) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers) Router(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router) RouterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.RouterKey)

Example 77 with Router

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router in project netvirt by opendaylight.

the class NeutronvpnUtils method getVpnForRouter.

// @param external vpn - true if external vpn being fetched, false for internal vpn
protected Uuid getVpnForRouter(Uuid routerId, Boolean externalVpn) {
    if (routerId == null) {
        return null;
    }
    InstanceIdentifier<VpnMaps> vpnMapsIdentifier = InstanceIdentifier.builder(VpnMaps.class).build();
    Optional<VpnMaps> optionalVpnMaps = read(LogicalDatastoreType.CONFIGURATION, vpnMapsIdentifier);
    if (optionalVpnMaps.isPresent() && optionalVpnMaps.get().getVpnMap() != null) {
        List<VpnMap> allMaps = optionalVpnMaps.get().getVpnMap();
        for (VpnMap vpnMap : allMaps) {
            if (routerId.equals(vpnMap.getRouterId())) {
                if (externalVpn) {
                    if (!routerId.equals(vpnMap.getVpnId())) {
                        return vpnMap.getVpnId();
                    }
                } else {
                    if (routerId.equals(vpnMap.getVpnId())) {
                        return vpnMap.getVpnId();
                    }
                }
            }
        }
    }
    LOG.debug("getVpnForRouter: Failed for router {} as no VPN present in VPNMaps DS", routerId.getValue());
    return null;
}
Also used : VpnMaps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps) VpnMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap)

Example 78 with Router

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router 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;
}
Also used : PortSecurityExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.portsecurity.rev150712.PortSecurityExtension)

Example 79 with Router

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router 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;
}
Also used : VpnInstance(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RpcError(org.opendaylight.yangtools.yang.common.RpcError) ArrayList(java.util.ArrayList) Evpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createevpn.input.Evpn) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) CreateEVPNOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.CreateEVPNOutputBuilder)

Example 80 with Router

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router in project netvirt by opendaylight.

the class NeutronvpnManager method associateRouterToVpn.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
protected void associateRouterToVpn(Uuid vpnId, Uuid routerId) {
    updateVpnMaps(vpnId, null, routerId, null, null);
    LOG.debug("Updating association of subnets to external vpn {}", vpnId.getValue());
    List<Uuid> routerSubnets = neutronvpnUtils.getNeutronRouterSubnetIds(routerId);
    for (Uuid subnetId : routerSubnets) {
        Subnetmap sn = updateVpnForSubnet(routerId, vpnId, subnetId, true);
        if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToAdd(sn, vpnId)) {
            neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), NeutronvpnUtils.getIpVersionFromString(sn.getSubnetIp()), true);
        }
    }
    try {
        checkAndPublishRouterAssociatedtoVpnNotification(routerId, vpnId);
        LOG.debug("notification upon association of router {} to VPN {} published", routerId.getValue(), vpnId.getValue());
    } catch (Exception e) {
        LOG.error("publishing of notification upon association of router {} to VPN {} failed : ", routerId.getValue(), vpnId.getValue(), e);
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)93 BigInteger (java.math.BigInteger)60 ArrayList (java.util.ArrayList)46 ExecutionException (java.util.concurrent.ExecutionException)27 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)24 Routers (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers)24 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)23 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)21 ProviderTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes)20 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)20 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)19 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)15 ExternalIps (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps)14 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)13 UnknownHostException (java.net.UnknownHostException)12 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)12 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)11 RouterPorts (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts)11 List (java.util.List)10 InternalToExternalPortMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap)10