Search in sources :

Example 26 with Transport

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project netconf by opendaylight.

the class IetfZeroTouchCallHomeServerProvider method createOperationalDevice.

private Device createOperationalDevice(final Device cfgDevice, final Device1 devStatus) {
    final DeviceBuilder deviceBuilder = new DeviceBuilder().addAugmentation(devStatus).setUniqueId(cfgDevice.getUniqueId());
    if (cfgDevice.getTransport() instanceof Ssh) {
        final String hostKey = ((Ssh) cfgDevice.getTransport()).getSshClientParams().getHostKey();
        final SshClientParams params = new SshClientParamsBuilder().setHostKey(hostKey).build();
        final Transport sshTransport = new SshBuilder().setSshClientParams(params).build();
        deviceBuilder.setTransport(sshTransport);
    } else if (cfgDevice.getTransport() instanceof Tls) {
        deviceBuilder.setTransport(cfgDevice.getTransport());
    } else if (cfgDevice.getSshHostKey() != null) {
        deviceBuilder.setSshHostKey(cfgDevice.getSshHostKey());
    }
    return deviceBuilder.build();
}
Also used : DeviceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.DeviceBuilder) SshClientParams(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.transport.ssh.SshClientParams) SshClientParamsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.transport.ssh.SshClientParamsBuilder) SshBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.transport.SshBuilder) Ssh(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.transport.Ssh) Tls(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.transport.Tls) Transport(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport)

Example 27 with Transport

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.

the class ItmTepInstanceRecoveryHandler method extractDPNTepsInfo.

private DPNTEPsInfo extractDPNTepsInfo(String entityId) {
    String[] params = entityId.split(":");
    if (params.length < 2) {
        LOG.error("Not enough arguments..Exiting...");
        return null;
    } else if (params.length > 2) {
        LOG.info("Ignoring extra parameter and proceeding...");
    }
    // ToDo:- Need to add more validations
    this.tzName = params[0];
    String ipAddress = params[1];
    transportZone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
    if (transportZone == null) {
        LOG.error("Transportzone name {} is not valid.", tzName);
        return null;
    }
    for (Subnets sub : transportZone.getSubnets()) {
        if (sub.getVteps() == null || sub.getVteps().isEmpty()) {
            LOG.error("Transport Zone {} subnet {} has no vteps", transportZone.getZoneName(), sub.getPrefix());
        }
        for (Vteps vtep : sub.getVteps()) {
            if (ipAddress.equals(String.valueOf(vtep.getIpAddress().getValue()))) {
                List<TzMembership> zones = ItmUtils.createTransportZoneMembership(tzName);
                LOG.trace("Transportzone {} found match for tep {} to be recovered", transportZone.getZoneName(), ipAddress);
                // OfTunnels is false byDefault
                TunnelEndPoints tunnelEndPoints = ItmUtils.createTunnelEndPoints(vtep.getDpnId(), IpAddressBuilder.getDefaultInstance(ipAddress), vtep.getPortname(), false, sub.getVlanId(), sub.getPrefix(), sub.getGatewayIp(), zones, transportZone.getTunnelType(), itmConfig.getDefaultTunnelTos());
                List<TunnelEndPoints> teps = new ArrayList<>();
                teps.add(tunnelEndPoints);
                return ItmUtils.createDPNTepInfo(vtep.getDpnId(), teps);
            }
        }
    }
    return null;
}
Also used : TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) ArrayList(java.util.ArrayList) TzMembership(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership)

Example 28 with Transport

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.

the class ItmManagerRpcService method getTunnelEndPointByDpnIdFromTranPortZone.

private Map<BigInteger, ComputesBuilder> getTunnelEndPointByDpnIdFromTranPortZone(Collection<BigInteger> dpnIds) throws ReadFailedException {
    TransportZones transportZones = singleTransactionDataBroker.syncRead(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(TransportZones.class).build());
    if (transportZones.getTransportZone() == null || transportZones.getTransportZone().isEmpty()) {
        throw new IllegalStateException("Failed to find transport zones in config datastore");
    }
    Map<BigInteger, ComputesBuilder> result = new HashMap<>();
    for (TransportZone transportZone : transportZones.getTransportZone()) {
        if (transportZone.getSubnets() == null || transportZone.getSubnets().isEmpty()) {
            LOG.debug("Transport Zone {} has no subnets", transportZone.getZoneName());
            continue;
        }
        for (Subnets sub : transportZone.getSubnets()) {
            if (sub.getVteps() == null || sub.getVteps().isEmpty()) {
                LOG.debug("Transport Zone {} subnet {} has no vteps configured", transportZone.getZoneName(), sub.getPrefix());
                continue;
            }
            for (Vteps vtep : sub.getVteps()) {
                if (dpnIds.contains(vtep.getDpnId())) {
                    result.putIfAbsent(vtep.getDpnId(), new ComputesBuilder().setZoneName(transportZone.getZoneName()).setPrefix(sub.getPrefix()).setDpnId(vtep.getDpnId()).setPortName(vtep.getPortname()).setNodeId(getNodeId(vtep.getDpnId())).setTepIp(Collections.singletonList(vtep.getIpAddress())));
                }
            }
        }
    }
    for (BigInteger dpnId : dpnIds) {
        if (!result.containsKey(dpnId)) {
            throw new IllegalStateException("Failed to find dpn id " + dpnId + " in transport zone");
        }
    }
    return result;
}
Also used : Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) HashMap(java.util.HashMap) ComputesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.get.dpn.info.output.ComputesBuilder) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) DeviceVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps) BigInteger(java.math.BigInteger) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)

Example 29 with Transport

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.

the class OvsdbTepRemoveConfigHelper method removeTepReceivedFromOvsdb.

/**
 * Removes the TEP from ITM configuration/operational Datastore in one of the following cases.
 * 1) default transport zone
 * 2) Configured transport zone
 * 3) Unhosted transport zone
 * Function checks for above three cases and calls other sub-function to remove the TEP
 *
 * @param tepIp TEP-IP address in string
 * @param strDpnId bridge datapath ID in string
 * @param tzName transport zone name in string
 * @param dataBroker data broker handle to perform operations on config/operational datastore
 * @param wrTx WriteTransaction object
 */
public static void removeTepReceivedFromOvsdb(String tepIp, String strDpnId, String tzName, DataBroker dataBroker, WriteTransaction wrTx) {
    BigInteger dpnId = BigInteger.valueOf(0);
    LOG.trace("Remove TEP: TEP-IP: {}, TZ name: {}, DPID: {}", tepIp, tzName, strDpnId);
    if (strDpnId != null && !strDpnId.isEmpty()) {
        dpnId = MDSALUtil.getDpnId(strDpnId);
    }
    // Get tep IP
    IpAddress tepIpAddress = IpAddressBuilder.getDefaultInstance(tepIp);
    TransportZone transportZone = null;
    // Case: TZ name is not given from OVS's other_config parameters.
    if (tzName == null) {
        tzName = ITMConstants.DEFAULT_TRANSPORT_ZONE;
        // add TEP into default-TZ
        transportZone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
        if (transportZone == null) {
            LOG.error("Error: default-transport-zone is not yet created.");
            return;
        }
        LOG.trace("Remove TEP from default-transport-zone.");
    } else {
        // Case: Add TEP into corresponding TZ created from Northbound.
        transportZone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
        if (transportZone == null) {
            // Case: TZ is not configured from Northbound, then add TEP into
            // "teps-in-not-hosted-transport-zone"
            LOG.trace("Removing TEP from teps-in-not-hosted-transport-zone list.");
            removeUnknownTzTepFromTepsNotHosted(tzName, tepIpAddress, dpnId, dataBroker, wrTx);
            return;
        } else {
            LOG.trace("Remove TEP from transport-zone already configured by Northbound.");
        }
    }
    // Remove TEP from (default transport-zone) OR (transport-zone already configured by Northbound)
    // Get subnet list of corresponding TZ created from Northbound.
    List<Subnets> subnetList = transportZone.getSubnets();
    if (subnetList == null || subnetList.isEmpty()) {
        LOG.trace("No subnet list in transport-zone. Nothing to do.");
    } else {
        IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
        List<Vteps> vtepList = null;
        // subnet list already exists case; check for dummy-subnet
        for (Subnets subnet : subnetList) {
            if (subnet.getKey().getPrefix().equals(subnetMaskObj)) {
                LOG.trace("Subnet exists in the subnet list of transport-zone {}.", tzName);
                // get vtep list of existing subnet
                vtepList = subnet.getVteps();
                break;
            }
        }
        if (vtepList == null || vtepList.isEmpty()) {
            // case: vtep list does not exist or it has no elements
            LOG.trace("No vtep list in subnet list of transport-zone. Nothing to do.");
        } else {
            // case: vtep list has elements
            boolean vtepFound = false;
            Vteps oldVtep = null;
            for (Vteps vtep : vtepList) {
                if (vtep.getDpnId().equals(dpnId)) {
                    vtepFound = true;
                    oldVtep = vtep;
                    break;
                }
            }
            if (vtepFound) {
                // vtep is found, update it with tep-ip
                LOG.trace("Remove TEP from vtep list in subnet list of transport-zone.");
                dpnId = oldVtep.getDpnId();
                String portName = oldVtep.getPortname();
                removeVtepFromTZConfig(subnetMaskObj, tzName, dpnId, portName, wrTx);
            } else {
                LOG.trace("TEP is not found in the vtep list in subnet list of transport-zone. Nothing to do.");
            }
        }
    }
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) UnknownVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)

Example 30 with Transport

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.

the class OvsdbTepRemoveConfigHelper method removeVtepFromTZConfig.

/**
 * Removes the TEP from subnet list in the transport zone list
 * from ITM configuration Datastore by delete operation with write transaction.
 *
 * @param subnetMaskObj subnet mask in IpPrefix object
 * @param dpnId bridge datapath ID in BigInteger
 * @param tzName transport zone name in string
 * @param portName port name as a part of VtepsKey
 * @param wrTx WriteTransaction object
 */
private static void removeVtepFromTZConfig(IpPrefix subnetMaskObj, String tzName, BigInteger dpnId, String portName, WriteTransaction wrTx) {
    SubnetsKey subnetsKey = new SubnetsKey(subnetMaskObj);
    VtepsKey vtepkey = new VtepsKey(dpnId, portName);
    InstanceIdentifier<Vteps> vtepPath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzName)).child(Subnets.class, subnetsKey).child(Vteps.class, vtepkey).build();
    LOG.trace("Removing TEP from (TZ: {} Subnet: {} DPN-ID: {}) inside ITM Config DS.", tzName, subnetMaskObj, dpnId);
    // remove vtep
    wrTx.delete(LogicalDatastoreType.CONFIGURATION, vtepPath);
}
Also used : SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey) VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey) UnknownVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsKey) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) UnknownVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone) TepsInNotHostedTransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

Aggregations

ArrayList (java.util.ArrayList)24 UnknownVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps)24 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)24 TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)21 UnknownVtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsKey)20 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps)17 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)16 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)16 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)15 List (java.util.List)13 VtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey)13 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)12 TransportZones (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones)12 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)12 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)11 Map (java.util.Map)11 Test (org.junit.Test)11 TepsInNotHostedTransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey)11 Optional (java.util.Optional)10 Inject (javax.inject.Inject)10