Search in sources :

Example 1 with ResetAction

use of io.lighty.netconf.device.action.actions.ResetAction in project lighty-netconf-simulator by PANTHEONtech.

the class ActionServiceDeviceProcessor method execute.

@Override
protected CompletableFuture<Response> execute(final Element requestXmlElement) {
    final XmlElement fromDomElement = XmlElement.fromDomElement(requestXmlElement);
    final Optional<Entry<Absolute, ActionDefinition>> actionEntry = findActionInElement(fromDomElement);
    Preconditions.checkState(actionEntry.isPresent(), "Action is not present on the device.");
    if (actionEntry.get().getValue().getQName().equals(Start.QNAME)) {
        this.actionProcessor = new StartActionProcessor(new StartAction(), actionEntry.get().getKey(), actionEntry.get().getValue(), this.adapterContext.currentSerializer());
    }
    if (actionEntry.get().getValue().getQName().equals(Reset.QNAME)) {
        this.actionProcessor = new ResetActionProcessor(new ResetAction(), actionEntry.get().getKey(), actionEntry.get().getValue(), this.adapterContext.currentSerializer());
    }
    Preconditions.checkState(this.actionProcessor != null, "Action is not implemented on the device.");
    this.actionProcessor.init(getNetconfDeviceServices());
    return this.actionProcessor.execute(requestXmlElement);
}
Also used : StartAction(io.lighty.netconf.device.action.actions.StartAction) Entry(java.util.Map.Entry) ResetAction(io.lighty.netconf.device.action.actions.ResetAction) XmlElement(org.opendaylight.netconf.api.xml.XmlElement)

Aggregations

ResetAction (io.lighty.netconf.device.action.actions.ResetAction)1 StartAction (io.lighty.netconf.device.action.actions.StartAction)1 Entry (java.util.Map.Entry)1 XmlElement (org.opendaylight.netconf.api.xml.XmlElement)1