Search in sources :

Example 1 with Operations

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);
        }
    }
}
Also used : OvsdbNodeAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) OvsdbTepInfo(org.opendaylight.genius.itm.commons.OvsdbTepInfo) OvsdbTepAddWorker(org.opendaylight.genius.itm.confighelpers.OvsdbTepAddWorker)

Example 2 with Operations

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);
            }
        }
    }
}
Also used : TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone) UnknownVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps)

Example 3 with Operations

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;
}
Also used : OvsdbBridgeAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation) TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)

Example 4 with Operations

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();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ReinstallOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.rpcs.rev170711.ReinstallOutputBuilder) OperationsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.ops.rev170711.service.ops.services.OperationsBuilder) EntityTypeService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.types.rev170711.EntityTypeService) ExecutionException(java.util.concurrent.ExecutionException) Operations(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.ops.rev170711.service.ops.services.Operations)

Example 5 with Operations

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();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) RpcFailEntityId(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.rpcs.rev170711.RpcFailEntityId) RpcFailEntityType(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.rpcs.rev170711.RpcFailEntityType) RpcSuccess(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.rpcs.rev170711.RpcSuccess) RecoverOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.rpcs.rev170711.RecoverOutputBuilder) OperationsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.ops.rev170711.service.ops.services.OperationsBuilder) RpcFailEntityName(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.rpcs.rev170711.RpcFailEntityName) EntityTypeInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.types.rev170711.EntityTypeInstance) ExecutionException(java.util.concurrent.ExecutionException) Operations(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.ops.rev170711.service.ops.services.Operations)

Aggregations

TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)5 UnknownVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps)4 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)3 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)3 BigInteger (java.math.BigInteger)2 ExecutionException (java.util.concurrent.ExecutionException)2 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)2 OvsdbTepInfo (org.opendaylight.genius.itm.commons.OvsdbTepInfo)2 OvsdbTepAddWorker (org.opendaylight.genius.itm.confighelpers.OvsdbTepAddWorker)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)2 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets)2 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)2 Operations (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.ops.rev170711.service.ops.services.Operations)2 OperationsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.ops.rev170711.service.ops.services.OperationsBuilder)2 OvsdbNodeAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation)2 ArrayList (java.util.ArrayList)1 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)1 OvsdbTepRemoveWorker (org.opendaylight.genius.itm.confighelpers.OvsdbTepRemoveWorker)1 TepsInNotHostedTransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey)1