Search in sources :

Example 71 with Uuid

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid in project netvirt by opendaylight.

the class WeightedCentralizedSwitchScheduler method deleteFromDpnMaps.

private void deleteFromDpnMaps(String routerName, List<Uuid> deletedSubnetIds, BigInteger primarySwitchId) {
    if (deletedSubnetIds == null || deletedSubnetIds.isEmpty()) {
        LOG.debug("deleteFromDpnMaps no subnets associated with {}", routerName);
        return;
    }
    WriteTransaction writeOperTxn = dataBroker.newWriteOnlyTransaction();
    String primaryRd = NatUtil.getPrimaryRd(dataBroker, routerName);
    for (Uuid subnetUuid : deletedSubnetIds) {
        String routerPort = subnetIdToRouterPortMap.remove(subnetUuid.getValue());
        if (routerPort == null) {
            LOG.error("The router port was not found for {}", subnetUuid.getValue());
            continue;
        }
        vpnFootprintService.updateVpnToDpnMapping(primarySwitchId, routerName, primaryRd, routerPort, null, false);
        NatUtil.removeFromNeutronRouterDpnsMap(dataBroker, routerName, primarySwitchId, writeOperTxn);
        NatUtil.removeFromDpnRoutersMap(dataBroker, routerName, routerName, interfaceManager, writeOperTxn);
    }
    writeOperTxn.submit();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Example 72 with Uuid

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid in project netvirt by opendaylight.

the class WeightedCentralizedSwitchScheduler method updateCentralizedSwitch.

@Override
public boolean updateCentralizedSwitch(Routers oldRouter, Routers newRouter) {
    String routerName = newRouter.getRouterName();
    List<Uuid> addedSubnetIds = getUpdatedSubnetIds(newRouter.getSubnetIds(), oldRouter.getSubnetIds());
    List<Uuid> deletedSubnetIds = getUpdatedSubnetIds(oldRouter.getSubnetIds(), newRouter.getSubnetIds());
    BigInteger primarySwitchId = NatUtil.getPrimaryNaptfromRouterName(dataBroker, newRouter.getRouterName());
    addToDpnMaps(routerName, addedSubnetIds, primarySwitchId);
    deleteFromDpnMaps(routerName, deletedSubnetIds, primarySwitchId);
    return true;
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) BigInteger(java.math.BigInteger)

Example 73 with Uuid

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid in project netvirt by opendaylight.

the class WeightedCentralizedSwitchScheduler method getUpdatedSubnetIds.

public static List<Uuid> getUpdatedSubnetIds(List<Uuid> updatedSubnetIds, List<Uuid> currentSubnetIds) {
    if (updatedSubnetIds == null) {
        return null;
    }
    List<Uuid> newSubnetIds = new ArrayList<>(updatedSubnetIds);
    if (currentSubnetIds == null) {
        return newSubnetIds;
    }
    List<Uuid> origSubnetIds = new ArrayList<>(currentSubnetIds);
    for (Iterator<Uuid> iterator = newSubnetIds.iterator(); iterator.hasNext(); ) {
        Uuid updatedSubnetId = iterator.next();
        for (Uuid currentSubnetId : origSubnetIds) {
            if (updatedSubnetId.getValue().equals(currentSubnetId.getValue())) {
                iterator.remove();
                break;
            }
        }
    }
    return newSubnetIds;
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList)

Example 74 with Uuid

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid in project netvirt by opendaylight.

the class AbstractSnatService method installSnatCommonEntriesForNonNaptSwitch.

protected void installSnatCommonEntriesForNonNaptSwitch(Routers routers, BigInteger primarySwitchId, BigInteger dpnId, int addOrRemove) {
    String routerName = routers.getRouterName();
    Long routerId = NatUtil.getVpnId(dataBroker, routerName);
    List<ExternalIps> externalIps = routers.getExternalIps();
    if (externalIps.isEmpty()) {
        LOG.error("AbstractSnatService: installSnatCommonEntriesForNaptSwitch no externalIP present" + " for routerId {}", routerId);
        return;
    }
    String externalIp = externalIps.get(0).getIpAddress();
    Uuid externalSubnetId = externalIps.get(0).getSubnetId();
    long extSubnetId = NatConstants.INVALID_ID;
    if (addOrRemove == NwConstants.ADD_FLOW) {
        extSubnetId = NatUtil.getExternalSubnetVpnId(dataBroker, externalSubnetId);
    }
    installDefaultFibRouteForSNAT(dpnId, routerId, addOrRemove);
    installSnatMissEntry(dpnId, routerId, routerName, primarySwitchId, externalIp, extSubnetId, addOrRemove);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ExternalIps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps)

Example 75 with Uuid

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid in project netvirt by opendaylight.

the class NeutronUtils method writePortStatus.

private static boolean writePortStatus(String uuid, String portStatus, DataBroker dataBroker, boolean create) {
    Uuid uuidObj = new Uuid(uuid);
    PortBuilder portBuilder = new PortBuilder();
    portBuilder.setUuid(uuidObj);
    portBuilder.setStatus(portStatus);
    InstanceIdentifier iid = InstanceIdentifier.create(Neutron.class).child(Ports.class).child(Port.class, new PortKey(uuidObj));
    SingleTransactionDataBroker tx = new SingleTransactionDataBroker(dataBroker);
    try {
        if (create) {
            tx.syncWrite(LogicalDatastoreType.OPERATIONAL, iid, portBuilder.build());
        } else {
            tx.syncUpdate(LogicalDatastoreType.OPERATIONAL, iid, portBuilder.build());
        }
    } catch (TransactionCommitFailedException e) {
        LOG.error("writePortStatus: failed neutron port status write. isCreate: {}", create, e);
        return false;
    }
    return true;
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) PortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortBuilder) PortKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortKey) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)283 ArrayList (java.util.ArrayList)114 BigInteger (java.math.BigInteger)79 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)55 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)53 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)52 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)48 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)40 ExecutionException (java.util.concurrent.ExecutionException)35 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)32 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)29 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)27 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)25 HashSet (java.util.HashSet)23 List (java.util.List)23 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)23 ProviderTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes)22 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)19 Optional (com.google.common.base.Optional)17 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)17