use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.ops.rev170711.service.ops.services.Operations in project genius by opendaylight.
the class OvsdbNodeListener method processBridgeUpdate.
private void processBridgeUpdate(OvsdbBridgeAugmentation ovsdbNewBridgeAugmentation) {
String bridgeName = null;
String strDpnId = null;
OvsdbNodeAugmentation ovsdbNewNodeAugmentation = null;
if (ovsdbNewBridgeAugmentation != null) {
bridgeName = ovsdbNewBridgeAugmentation.getBridgeName().getValue();
// Read DPID from OVSDBBridgeAugmentation
strDpnId = ItmUtils.getStrDatapathId(ovsdbNewBridgeAugmentation);
if (strDpnId == null || strDpnId.isEmpty()) {
LOG.info("OvsdbBridgeAugmentation processBridgeUpdate: DPID for bridge {} is NULL.", bridgeName);
return;
}
// TBD: Move this time taking operations into DataStoreJobCoordinator
Node ovsdbNodeFromBridge = ItmUtils.getOvsdbNode(ovsdbNewBridgeAugmentation, dataBroker);
// check for OVSDB node
if (ovsdbNodeFromBridge != null) {
ovsdbNewNodeAugmentation = ovsdbNodeFromBridge.getAugmentation(OvsdbNodeAugmentation.class);
} else {
LOG.error("processBridgeUpdate: Ovsdb Node could not be fetched from Oper DS for bridge {}.", bridgeName);
return;
}
}
if (ovsdbNewNodeAugmentation != null) {
OvsdbTepInfo ovsdbTepInfo = getOvsdbTepInfo(ovsdbNewNodeAugmentation);
if (ovsdbTepInfo == null) {
LOG.trace("processBridgeUpdate: No Tep Info");
return;
}
// store TEP info required parameters
String newLocalIp = ovsdbTepInfo.getLocalIp();
String tzName = ovsdbTepInfo.getTzName();
String newBridgeName = ovsdbTepInfo.getBrName();
boolean ofTunnel = ovsdbTepInfo.getOfTunnel();
// check if Local IP is configured or not
if (newLocalIp != null && !newLocalIp.isEmpty()) {
// if it is br-int, then add TEP into Config DS
if (newBridgeName.equals(bridgeName)) {
LOG.trace("Ovs Node with bridge {} is configured with Local IP.", bridgeName);
// if flag is OFF, then no need to add TEP into ITM config DS.
if (tzName == null || tzName.equals(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
boolean defTzEnabled = itmConfig.isDefTzEnabled();
if (!defTzEnabled) {
LOG.info("TEP ({}) cannot be added into {} when def-tz-enabled flag is false.", newLocalIp, ITMConstants.DEFAULT_TRANSPORT_ZONE);
return;
}
}
LOG.trace("Local-IP: {}, TZ name: {}, Bridge Name: {}, Bridge DPID: {}," + "of-tunnel flag: {}", newLocalIp, tzName, newBridgeName, strDpnId, ofTunnel);
// Enqueue 'add TEP into new TZ' operation into DataStoreJobCoordinator
jobCoordinator.enqueueJob(newLocalIp, new OvsdbTepAddWorker(newLocalIp, strDpnId, tzName, ofTunnel, dataBroker));
} else {
LOG.trace("TEP ({}) would be added later when bridge {} gets added into Ovs Node.", newLocalIp, newBridgeName);
}
} else {
LOG.trace("Ovs Node with bridge {} is not configured with Local IP. Nothing to do.", bridgeName);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.ops.rev170711.service.ops.services.Operations in project genius by opendaylight.
the class OvsdbTepRemoveConfigHelper method removeUnknownTzTepFromTepsNotHosted.
/**
* Removes the TEP from the not-hosted transport zone in the TepsNotHosted list
* from ITM Operational Datastore.
*
* @param tzName transport zone name in string
* @param tepIpAddress TEP IP address in IpAddress object
* @param dpnId bridge datapath ID in BigInteger
* @param dataBroker data broker handle to perform operations on operational datastore
* @param wrTx WriteTransaction object
*/
public static void removeUnknownTzTepFromTepsNotHosted(String tzName, IpAddress tepIpAddress, BigInteger dpnId, DataBroker dataBroker, WriteTransaction wrTx) {
List<UnknownVteps> vtepList = null;
TepsInNotHostedTransportZone tepsInNotHostedTransportZone = ItmUtils.getUnknownTransportZoneFromITMOperDS(tzName, dataBroker);
if (tepsInNotHostedTransportZone == null) {
LOG.trace("Unhosted TransportZone ({}) does not exist in OperDS. Nothing to do for TEP removal.", tzName);
return;
} else {
vtepList = tepsInNotHostedTransportZone.getUnknownVteps();
if (vtepList == null || vtepList.isEmpty()) {
// case: vtep list does not exist or it has no elements
LOG.trace("Remove TEP from unhosted TZ ({}) when no vtep-list in the TZ. Nothing to do.", tzName);
} else {
// case: vtep list has elements
boolean vtepFound = false;
UnknownVteps foundVtep = null;
for (UnknownVteps vtep : vtepList) {
if (vtep.getDpnId().equals(dpnId)) {
vtepFound = true;
foundVtep = vtep;
break;
}
}
if (vtepFound) {
// vtep is found, update it with tep-ip
LOG.trace("Remove TEP with IP ({}) from unhosted TZ ({}) inside not-hosted-transport-zones list.", tepIpAddress, tzName);
if (vtepList.size() == 1) {
removeTzFromTepsNotHosted(tzName, wrTx);
} else {
removeVtepFromTepsNotHosted(tzName, dpnId, wrTx);
}
vtepList.remove(foundVtep);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.ops.rev170711.service.ops.services.Operations in project genius by opendaylight.
the class ItmUtils method getBridgeDpid.
/**
* Gets the bridge datapath ID from Network topology Node's OvsdbBridgeAugmentation, in the Operational DS.
*
* @param node Network Topology Node
*
* @param bridge bridge name
*
* @param dataBroker data broker handle to perform operations on datastore
*
* @return the datapath ID of bridge in string form
*/
public static String getBridgeDpid(Node node, String bridge, DataBroker dataBroker) {
OvsdbBridgeAugmentation ovsdbBridgeAugmentation = null;
Node bridgeNode = null;
String datapathId = null;
NodeId ovsdbNodeId = node.getKey().getNodeId();
NodeId brNodeId = new NodeId(ovsdbNodeId.getValue() + "/" + ITMConstants.BRIDGE_URI_PREFIX + "/" + bridge);
InstanceIdentifier<Node> bridgeIid = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(IfmConstants.OVSDB_TOPOLOGY_ID)).child(Node.class, new NodeKey(brNodeId));
Optional<Node> opBridgeNode = ItmUtils.read(LogicalDatastoreType.OPERATIONAL, bridgeIid, dataBroker);
if (opBridgeNode.isPresent()) {
bridgeNode = opBridgeNode.get();
}
if (bridgeNode != null) {
ovsdbBridgeAugmentation = bridgeNode.getAugmentation(OvsdbBridgeAugmentation.class);
}
if (ovsdbBridgeAugmentation != null && ovsdbBridgeAugmentation.getDatapathId() != null) {
datapathId = ovsdbBridgeAugmentation.getDatapathId().getValue();
}
return datapathId;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.ops.rev170711.service.ops.services.Operations in project genius by opendaylight.
the class SrmRpcUtils method callSrmOp.
public static ReinstallOutput callSrmOp(DataBroker broker, ReinstallInput input) {
ReinstallOutputBuilder outputBuilder = new ReinstallOutputBuilder();
if (input.getEntityName() == null) {
outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage("EntityName is null");
return outputBuilder.build();
}
if (input.getEntityType() == null) {
outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(String.format("EntityType for %s can't be null", input.getEntityName().getSimpleName()));
return outputBuilder.build();
}
if (!EntityTypeService.class.equals(input.getEntityType())) {
outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(String.format("EntityType is %s, Reinstall is only for EntityTypeService", input.getEntityType()));
return outputBuilder.build();
}
Class<? extends EntityNameBase> serviceName = NAME_TO_SERVICE_MAP.get(input.getEntityName());
if (serviceName == null) {
outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(String.format("EntityName %s has no matching service", input.getEntityName().getSimpleName()));
return outputBuilder.build();
}
Class<? extends EntityTypeBase> entityType = NAME_TO_TYPE_MAP.get(input.getEntityName());
if (entityType == null || !input.getEntityType().equals(entityType)) {
outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(String.format("EntityName %s doesn't match with EntityType %s", input.getEntityName().getSimpleName(), entityType));
return outputBuilder.build();
}
OperationsBuilder opsBuilder = new OperationsBuilder().setEntityName(input.getEntityName()).setEntityType(entityType).setTriggerOperation(ServiceOpReinstall.class);
Operations operation = opsBuilder.build();
InstanceIdentifier<Operations> opsIid = getInstanceIdentifier(operation, serviceName);
WriteTransaction tx = broker.newWriteOnlyTransaction();
tx.put(LogicalDatastoreType.OPERATIONAL, opsIid, operation, CREATE_MISSING_PARENT);
try {
tx.submit().get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error writing RecoveryOp to datastore. path:{}, data:{}", opsIid, operation);
outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(e.getMessage());
return outputBuilder.build();
}
outputBuilder.setSuccessful(REINSTALL_SUCCESS).setMessage("Recovery operation successfully triggered");
return outputBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.ops.rev170711.service.ops.services.Operations in project genius by opendaylight.
the class SrmRpcUtils method callSrmOp.
public static RecoverOutput callSrmOp(DataBroker broker, RecoverInput input) {
RecoverOutputBuilder outputBuilder = new RecoverOutputBuilder();
if (input.getEntityName() == null) {
outputBuilder.setResponse(RpcFailEntityName.class).setMessage("EntityName is null");
return outputBuilder.build();
}
if (input.getEntityType() == null) {
outputBuilder.setResponse(RpcFailEntityType.class).setMessage(String.format("EntityType for %s can't be null", input.getEntityName().getSimpleName()));
return outputBuilder.build();
}
String entityId;
if (EntityTypeInstance.class.equals(input.getEntityType()) && input.getEntityId() == null) {
outputBuilder.setResponse(RpcFailEntityId.class).setMessage(String.format("EntityId can't be null for %s", input.getEntityName().getSimpleName()));
return outputBuilder.build();
} else {
entityId = input.getEntityId();
}
Class<? extends EntityNameBase> serviceName = NAME_TO_SERVICE_MAP.get(input.getEntityName());
if (serviceName == null) {
outputBuilder.setResponse(RpcFailEntityName.class).setMessage(String.format("EntityName %s has no matching service", input.getEntityName().getSimpleName()));
return outputBuilder.build();
}
Class<? extends EntityTypeBase> entityType = NAME_TO_TYPE_MAP.get(input.getEntityName());
if (entityType == null || !input.getEntityType().equals(entityType)) {
outputBuilder.setResponse(RpcFailEntityType.class).setMessage(String.format("EntityName %s doesn't match with EntityType %s", input.getEntityName().getSimpleName(), entityType));
return outputBuilder.build();
}
OperationsBuilder opsBuilder = new OperationsBuilder().setEntityName(input.getEntityName()).setEntityType(entityType).setTriggerOperation(ServiceOpRecover.class);
if (entityId != null) {
opsBuilder.setEntityId(entityId);
}
Operations operation = opsBuilder.build();
InstanceIdentifier<Operations> opsIid = getInstanceIdentifier(operation, serviceName);
WriteTransaction tx = broker.newWriteOnlyTransaction();
tx.put(LogicalDatastoreType.OPERATIONAL, opsIid, operation, CREATE_MISSING_PARENT);
try {
tx.submit().get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error writing RecoveryOp to datastore. path:{}, data:{}", opsIid, operation);
outputBuilder.setResponse(RpcFailUnknown.class).setMessage(e.getMessage());
return outputBuilder.build();
}
outputBuilder.setResponse(RpcSuccess.class).setMessage("Recovery operation successfully triggered");
return outputBuilder.build();
}
Aggregations