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();
}
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;
}
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;
}
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.");
}
}
}
}
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);
}
Aggregations