Search in sources :

Example 1 with VpnMaps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps in project netvirt by opendaylight.

the class NeutronvpnUtils method getNetworksForVpn.

protected List<Uuid> getNetworksForVpn(Uuid vpnId) {
    InstanceIdentifier<VpnMap> vpnMapIdentifier = InstanceIdentifier.builder(VpnMaps.class).child(VpnMap.class, new VpnMapKey(vpnId)).build();
    Optional<VpnMap> optionalVpnMap = read(LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier);
    if (optionalVpnMap.isPresent()) {
        VpnMap vpnMap = optionalVpnMap.get();
        return vpnMap.getNetworkIds();
    }
    LOG.error("getNetworksforVpn: Failed as VPNMaps DS is absent for VPN {}", vpnId.getValue());
    return null;
}
Also used : VpnMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap) VpnMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMapKey)

Example 2 with VpnMaps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps 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 3 with VpnMaps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps in project netvirt by opendaylight.

the class NeutronvpnManager method handleNeutronRouterDeleted.

protected void handleNeutronRouterDeleted(Uuid routerId, List<Uuid> routerSubnetIds) {
    // check if the router is associated to some VPN
    Uuid vpnId = neutronvpnUtils.getVpnForRouter(routerId, true);
    Uuid internetVpnId = neutronvpnUtils.getInternetvpnUuidBoundToRouterId(routerId);
    if (vpnId != null) {
        // remove existing external vpn interfaces
        for (Uuid subnetId : routerSubnetIds) {
            removeSubnetFromVpn(vpnId, subnetId, internetVpnId);
        }
        clearFromVpnMaps(vpnId, routerId, null);
    } else {
        // remove existing internal vpn interfaces
        for (Uuid subnetId : routerSubnetIds) {
            removeSubnetFromVpn(routerId, subnetId, internetVpnId);
        }
    }
    // delete entire vpnMaps node for internal VPN
    deleteVpnMapsNode(routerId);
    // delete vpn-instance for internal VPN
    deleteVpnInstance(routerId);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Example 4 with VpnMaps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps in project netvirt by opendaylight.

the class NeutronvpnManager method removeVpn.

public void removeVpn(Uuid id) {
    // read VPNMaps
    VpnMap vpnMap = neutronvpnUtils.getVpnMap(id);
    Uuid router = vpnMap != null ? vpnMap.getRouterId() : null;
    // dissociate router
    if (router != null) {
        dissociateRouterFromVpn(id, router);
    }
    // dissociate networks
    if (!id.equals(router) && vpnMap.getNetworkIds() != null) {
        dissociateNetworksFromVpn(id, vpnMap.getNetworkIds());
    }
    // remove entire vpnMaps node
    deleteVpnMapsNode(id);
    // remove vpn-instance
    deleteVpnInstance(id);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap)

Example 5 with VpnMaps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps in project netvirt by opendaylight.

the class NatUtil method getVpnForRouter.

static Uuid getVpnForRouter(DataBroker broker, String routerId) {
    InstanceIdentifier<VpnMaps> vpnMapsIdentifier = InstanceIdentifier.builder(VpnMaps.class).build();
    Optional<VpnMaps> optionalVpnMaps = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(broker, LogicalDatastoreType.CONFIGURATION, vpnMapsIdentifier);
    if (optionalVpnMaps.isPresent() && optionalVpnMaps.get().getVpnMap() != null) {
        List<VpnMap> allMaps = optionalVpnMaps.get().getVpnMap();
        if (routerId != null) {
            for (VpnMap vpnMap : allMaps) {
                if (vpnMap.getRouterId() != null && routerId.equals(vpnMap.getRouterId().getValue()) && !routerId.equals(vpnMap.getVpnId().getValue())) {
                    return vpnMap.getVpnId();
                }
            }
        }
    }
    LOG.debug("getVpnForRouter : VPN not found for routerID:{}", routerId);
    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)

Aggregations

VpnMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap)9 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)6 VpnMapKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMapKey)5 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)3 VpnMaps (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps)3 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)2 VpnMapBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMapBuilder)2 ArrayList (java.util.ArrayList)1 VpnInstances (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInstances)1 VpnTarget (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.af.config.vpntargets.VpnTarget)1 VpnInstance (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance)1 VpnInstanceKey (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstanceKey)1 GetL3VPNOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetL3VPNOutput)1 GetL3VPNOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetL3VPNOutputBuilder)1 L3vpnInstances (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.getl3vpn.output.L3vpnInstances)1 L3vpnInstancesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.getl3vpn.output.L3vpnInstancesBuilder)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1