leaf create-parents {
type boolean;
mandatory true;
+ default true;
status current;
description "Create parents if doesn't exist";
}
ForwardingRulesCommiter<TableFeatures> getTableFeaturesCommiter();
/**
- * Returns the config-subsystem/fallback configuration of FRM
- * @return ForwardingRulesManagerConfig
+ * Check if reconciliation is disabled by user.
+ * @return true if reconciliation is disabled, else false
*/
- ForwardingRulesManagerConfig getConfiguration();
+ boolean isReconciliationDisabled();
+
+ /**
+ * Check if stale marking is enabled for switch reconciliation.
+ * @return true if stale marking is enabled, else false
+ */
+ boolean isStaleMarkingEnabled();
+
+ /**
+ * Return number of reconciliation retry are allowed.
+ * @return number of retries.
+ */
+ int getReconciliationRetryCount();
/**
* Method checks if *this* instance of openflowplugin is owner of
}
}
else{
- if (provider.getConfiguration().isStaleMarkingEnabled()) {
+ if (provider.isStaleMarkingEnabled()) {
LOG.info("Stale-Marking ENABLED and switch {} is NOT connected, storing stale entities",
nodeIdent.toString());
// Switch is NOT connected
public void setDeviceOperationalStatus(boolean inOperDS) {
isDeviceInOperDS.set(inOperDS);
if(canReconcile()) {
- LOG.info("Triggering reconciliation for device {}", nodeId.getValue());
reconcliationAgent.reconcileConfiguration(fcnIID);
}
}
@Override
public void reconcileConfiguration(InstanceIdentifier<FlowCapableNode> connectedNode) {
+ if (provider.isReconciliationDisabled()) {
+ LOG.debug("Reconciliation is disabled by user. Skipping reconciliation of node : {}", connectedNode
+ .firstKeyOf(Node.class));
+ return;
+ }
if (provider.isNodeOwner(connectedNode)) {
- if (provider.getConfiguration().isStaleMarkingEnabled()) {
+ LOG.info("Triggering reconciliation for device {}", connectedNode.firstKeyOf(Node.class));
+ if (provider.isStaleMarkingEnabled()) {
LOG.info("Stale-Marking is ENABLED and proceeding with deletion of stale-marked entities on switch {}",
connectedNode.toString());
reconciliationPreProcess(connectedNode);
Map<Long, ListenableFuture<?>> groupFutures = new HashMap<>();
while ((!(toBeInstalledGroups.isEmpty()) || !(suspectedGroups.isEmpty())) &&
- (counter <= provider.getConfiguration().getReconciliationRetryCount())) { //also check if the counter has not crossed the threshold
+ (counter <= provider.getReconciliationRetryCount())) { //also check if the counter has not crossed the threshold
if (toBeInstalledGroups.isEmpty() && !suspectedGroups.isEmpty()) {
LOG.error("These Groups are pointing to node-connectors that are not up yet {}", suspectedGroups.toString());
if (!toBeInstalledGroups.isEmpty()) {
for (Group group : toBeInstalledGroups) {
LOG.error("Installing the group {} finally although the port is not up after checking for {} times "
- , group.getGroupId().toString(), provider.getConfiguration().getReconciliationRetryCount());
+ , group.getGroupId().toString(), provider.getReconciliationRetryCount());
addGroup(groupFutures, group);
}
}
import com.google.common.util.concurrent.CheckedFuture;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicLong;
+import javax.annotation.Nonnull;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
private final ForwardingRulesManagerConfig forwardingRulesManagerConfig;
private final ClusterSingletonServiceProvider clusterSingletonServiceProvider;
private final NotificationProviderService notificationService;
+ private final boolean disableReconciliation;
+ private final boolean staleMarkingEnabled;
+ private final int reconciliationRetryCount;
private ForwardingRulesCommiter<Flow> flowListener;
private ForwardingRulesCommiter<Group> groupListener;
final RpcConsumerRegistry rpcRegistry,
final ForwardingRulesManagerConfig config,
final ClusterSingletonServiceProvider clusterSingletonService,
- final NotificationProviderService notificationService) {
+ final NotificationProviderService notificationService,
+ final boolean disableReconciliation,
+ final boolean staleMarkingEnabled,
+ final int reconciliationRetryCount) {
this.dataService = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!");
this.forwardingRulesManagerConfig = Preconditions.checkNotNull(config, "Configuration for FRM cannot be null");
this.clusterSingletonServiceProvider = Preconditions.checkNotNull(clusterSingletonService,
"RPC SalMeterService not found.");
this.salTableService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalTableService.class),
"RPC SalTableService not found.");
+
+ this.disableReconciliation = disableReconciliation;
+ this.staleMarkingEnabled = staleMarkingEnabled;
+ this.reconciliationRetryCount = reconciliationRetryCount;
}
@Override
}
@Override
- public ForwardingRulesManagerConfig getConfiguration() {
- return forwardingRulesManagerConfig;
+ public boolean isReconciliationDisabled() {
+ return this.disableReconciliation;
+ }
+
+ @Override
+ public boolean isStaleMarkingEnabled() {
+ return this.staleMarkingEnabled;
+ }
+
+ @Override
+ public int getReconciliationRetryCount() {
+ return this.reconciliationRetryCount;
}
@Override
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
odl:use-default-for-reference-types="true">
<odl:clustered-app-config id="frmConfig"
binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig"/>
+ <cm:property-placeholder persistent-id="org.opendaylight.openflowplugin"
+ placeholder-prefix="${frm-"
+ update-strategy="none">
+ <cm:default-properties>
+ <!-- Disable switch reconciliation -->
+ <cm:property name="disable-reconciliation" value="false"/>
+ <!-- Enable stale marking for switch reconciliation -->
+ <cm:property name="stale-marking-enabled" value="false"/>
+ <!-- Number of retries for switch reconciliation -->
+ <cm:property name="reconciliation-retry-count" value="5"/>
+ </cm:default-properties>
+ </cm:property-placeholder>
+
<bean id="frmManager" class="org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl"
init-method="start" destroy-method="close">
<argument ref="dataBroker"/>
<argument ref="frmConfig"/>
<argument ref="clusterSingletonService"/>
<argument ref="notificationService"/>
+ <argument value="${frm-disable-reconciliation}"/>
+ <argument value="${frm-stale-marking-enabled}"/>
+ <argument value="${frm-reconciliation-retry-count}"/>
+
</bean>
</blueprint>
\ No newline at end of file
rpcProviderRegistryMock,
getConfig(),
clusterSingletonService,
- notificationService);
+ notificationService, false, false, 5);
forwardingRulesManager.start();
// TODO consider tests rewrite (added because of complicated access)
forwardingRulesManager.setDeviceMastershipManager(deviceMastershipManager);
rpcProviderRegistryMock,
getConfig(),
clusterSingletonService,
- notificationService);
+ notificationService, false, false, 5);
forwardingRulesManager.start();
// TODO consider tests rewrite (added because of complicated access)
forwardingRulesManager.setDeviceMastershipManager(deviceMastershipManager);
rpcProviderRegistryMock,
getConfig(),
clusterSingletonService,
- notificationService);
+ notificationService, false, false, 5);
forwardingRulesManager.start();
// TODO consider tests rewrite (added because of complicated access)
forwardingRulesManager.setDeviceMastershipManager(deviceMastershipManager);
rpcProviderRegistryMock,
getConfig(),
clusterSingletonService,
- notificationService);
+ notificationService, false ,false ,5);
forwardingRulesManager.start();
}
rpcProviderRegistryMock,
getConfig(),
clusterSingletonService,
- notificationService);
+ notificationService, false, false , 5);
forwardingRulesManager.start();
// TODO consider tests rewrite (added because of complicated access)
forwardingRulesManager.setDeviceMastershipManager(deviceMastershipManager);
# then to format supported by device, and reversed when deserializing.
#
# use-single-layer-serialization=true
+
+#############################################################################
+# #
+# Forwarding Rule Manager Application Configuration #
+# #
+#############################################################################
+
+# Disable the default switch reconciliation mechanism
+# disable-reconciliation=false
+
+# Enable stale marking for switch reconciliation. Once user enable this feature
+# forwarding rule manager will keep track of any change to the config data store
+# while the switch is disconnected from controller. Once switch reconnect to the
+# controller it will apply those changes to the switch and do the reconciliation
+# of other configuration as well.
+# NOTE: This option will be effective only if disable_reconciliation=false.
+# stale-marking-enabled=false
+
+# Number of time forwarding rules manager should retry to reconcile any specific
+# configuration.
+# reconciliation-retry-count=5
modifiable = false;
break;
default:
- LOG.warn("Unsupported configuration property '{}={}'", key, sValue);
return;
}
*/
package org.opendaylight.openflowplugin.openflow.md.core.extension;
+import java.util.Objects;
import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;
import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
import org.opendaylight.openflowplugin.extension.api.ConvertorActionFromOFJava;
+import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCase;
processAlienAction(final Action action, final OpenflowVersion ofVersion, final ActionPath actionPath) {
ConvertorActionFromOFJava<Action, ActionPath> convertor = null;
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action alienAction = null;
+ final ExtensionConverterProvider extensionConvertorProvider = OFSessionUtil.getExtensionConvertorProvider();
+
+ if (Objects.isNull(extensionConvertorProvider)) {
+ return null;
+ }
+
if(action.getActionChoice() instanceof ExperimenterIdCase) {
ExperimenterIdCase actionCase = (ExperimenterIdCase) action.getActionChoice();
/** TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL) */
ofVersion.getVersion(),
actionCase.getExperimenter().getExperimenter().getValue(),
actionCase.getExperimenter().getSubType());
- convertor = OFSessionUtil.getExtensionConvertorProvider().getActionConverter(key);
+ convertor = extensionConvertorProvider.getActionConverter(key);
} else if (action.getActionChoice() != null){
ActionSerializerKey<?> key = new ActionSerializerKey(EncodeConstants.OF13_VERSION_ID, action.getActionChoice().getImplementedInterface(), null);
- convertor = OFSessionUtil.getExtensionConvertorProvider().getActionConverter(key);
+ convertor = extensionConvertorProvider.getActionConverter(key);
}
+
if (convertor != null) {
- alienAction = convertor.convert(
- action, actionPath);
+ alienAction = convertor.convert(action, actionPath);
}
+
return alienAction;
}
}
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPushMplsCase;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPushPbbCase;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPushVlanCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetDlDstCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetDlSrcCase;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetFieldCase;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetMplsTtlCase;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetNwDstCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetNwSrcCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetNwTosCase;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetNwTtlCase;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetQueueCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetTpDstCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetTpSrcCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetVlanIdCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetVlanPcpCase;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalStripVlanCase;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
.addCase(new OfToSalGroupCase())
.addCase(new OfToSalOutputActionCase())
.addCase(new OfToSalPopMplsCase())
- .addCase(new OfToSalPopPbbCase())
.addCase(new OfToSalPopVlanCase())
.addCase(new OfToSalPushMplsCase())
.addCase(new OfToSalPushPbbCase())
.addCase(new OfToSalPushVlanCase())
- .addCase(new OfToSalSetFieldCase())
.addCase(new OfToSalSetMplsTtlCase())
- .addCase(new OfToSalSetNwDstCase())
.addCase(new OfToSalSetNwTtlCase())
.addCase(new OfToSalSetQueueCase())
+ // OpenFlow 1.3 specific actions
+ .addCase(new OfToSalPopPbbCase())
+ .addCase(new OfToSalSetFieldCase())
+ // OpenFlow 1.0 specific actions
+ .addCase(new OfToSalSetNwSrcCase())
+ .addCase(new OfToSalSetNwDstCase())
+ .addCase(new OfToSalSetNwTosCase())
+ .addCase(new OfToSalSetDlSrcCase())
+ .addCase(new OfToSalSetDlDstCase())
+ .addCase(new OfToSalSetTpSrcCase())
+ .addCase(new OfToSalSetTpDstCase())
+ .addCase(new OfToSalSetVlanPcpCase())
+ .addCase(new OfToSalSetVlanIdCase())
.addCase(new OfToSalStripVlanCase());
private static final Set<Class<? extends DataContainer>> TYPES = Collections.singleton(Action.class);
public class OfToSalPopPbbCase extends ConvertorCase<PopPbbCase, Action, ActionResponseConvertorData> {
public OfToSalPopPbbCase() {
- super(PopPbbCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ super(PopPbbCase.class, true, OFConstants.OFP_VERSION_1_3);
}
@Override
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCase;
+
+public class OfToSalSetDlDstCase extends ConvertorCase<SetDlDstCase, Action, ActionResponseConvertorData> {
+ public OfToSalSetDlDstCase() {
+ super(SetDlDstCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final SetDlDstCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+ return Optional.of(new SetDlDstActionCaseBuilder()
+ .setSetDlDstAction(new SetDlDstActionBuilder()
+ .setAddress(source.getSetDlDstAction().getDlDstAddress())
+ .build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCase;
+
+public class OfToSalSetDlSrcCase extends ConvertorCase<SetDlSrcCase, Action, ActionResponseConvertorData> {
+ public OfToSalSetDlSrcCase() {
+ super(SetDlSrcCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final SetDlSrcCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+ return Optional.of(new SetDlSrcActionCaseBuilder()
+ .setSetDlSrcAction(new SetDlSrcActionBuilder()
+ .setAddress(source.getSetDlSrcAction().getDlSrcAddress())
+ .build())
+ .build());
+ }
+}
public class OfToSalSetFieldCase extends ConvertorCase<SetFieldCase, Action, ActionResponseConvertorData> {
public OfToSalSetFieldCase() {
- super(SetFieldCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ super(SetFieldCase.class, true, OFConstants.OFP_VERSION_1_3);
}
@Override
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCase;
public class OfToSalSetNwDstCase extends ConvertorCase<SetNwDstCase, Action, ActionResponseConvertorData> {
public OfToSalSetNwDstCase() {
- super(SetNwDstCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ super(SetNwDstCase.class, true, OFConstants.OFP_VERSION_1_0);
}
@Override
public Optional<Action> process(@Nonnull final SetNwDstCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
- SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
- return Optional.of(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
+ return Optional.of(new SetNwDstActionCaseBuilder()
+ .setSetNwDstAction(new SetNwDstActionBuilder()
+ .setAddress(new Ipv4Builder()
+ .setIpv4Address(IpConversionUtil.createPrefix(source.getSetNwDstAction().getIpAddress()))
+ .build())
+ .build())
+ .build());
}
}
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCase;
+
+public class OfToSalSetNwSrcCase extends ConvertorCase<SetNwSrcCase, Action, ActionResponseConvertorData> {
+ public OfToSalSetNwSrcCase() {
+ super(SetNwSrcCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final SetNwSrcCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+ return Optional.of(new SetNwSrcActionCaseBuilder()
+ .setSetNwSrcAction(new SetNwSrcActionBuilder()
+ .setAddress(new Ipv4Builder()
+ .setIpv4Address(IpConversionUtil.createPrefix(source.getSetNwSrcAction().getIpAddress()))
+ .build())
+ .build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTosCase;
+
+public class OfToSalSetNwTosCase extends ConvertorCase<SetNwTosCase, Action, ActionResponseConvertorData> {
+ public OfToSalSetNwTosCase() {
+ super(SetNwTosCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final SetNwTosCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+ return Optional.of(new SetNwTosActionCaseBuilder()
+ .setSetNwTosAction(new SetNwTosActionBuilder()
+ .setTos((int) source.getSetNwTosAction().getNwTos())
+ .build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpDstCase;
+
+public class OfToSalSetTpDstCase extends ConvertorCase<SetTpDstCase, Action, ActionResponseConvertorData> {
+ public OfToSalSetTpDstCase() {
+ super(SetTpDstCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final SetTpDstCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+ return Optional.of(new SetTpDstActionCaseBuilder()
+ .setSetTpDstAction(new SetTpDstActionBuilder()
+ .setPort(new PortNumber(source.getSetTpDstAction().getPort().getValue().intValue()))
+ .setIpProtocol(data.getIpProtocol())
+ .build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCase;
+
+public class OfToSalSetTpSrcCase extends ConvertorCase<SetTpSrcCase, Action, ActionResponseConvertorData> {
+ public OfToSalSetTpSrcCase() {
+ super(SetTpSrcCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final SetTpSrcCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+ return Optional.of(new SetTpSrcActionCaseBuilder()
+ .setSetTpSrcAction(new SetTpSrcActionBuilder()
+ .setPort(new PortNumber(source.getSetTpSrcAction().getPort().getValue().intValue()))
+ .setIpProtocol(data.getIpProtocol())
+ .build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanVidCase;
+
+public class OfToSalSetVlanIdCase extends ConvertorCase<SetVlanVidCase, Action, ActionResponseConvertorData> {
+ public OfToSalSetVlanIdCase() {
+ super(SetVlanVidCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final SetVlanVidCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+ return Optional.of(new SetVlanIdActionCaseBuilder()
+ .setSetVlanIdAction(new SetVlanIdActionBuilder()
+ .setVlanId(new VlanId(source.getSetVlanVidAction().getVlanVid()))
+ .build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanPcpCase;
+
+public class OfToSalSetVlanPcpCase extends ConvertorCase<SetVlanPcpCase, Action, ActionResponseConvertorData> {
+ public OfToSalSetVlanPcpCase() {
+ super(SetVlanPcpCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final SetVlanPcpCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+ return Optional.of(new SetVlanPcpActionCaseBuilder()
+ .setSetVlanPcpAction(new SetVlanPcpActionBuilder()
+ .setVlanPcp(new VlanPcp(source.getSetVlanPcpAction().getVlanPcp()))
+ .build())
+ .build());
+ }
+}
public class OfToSalStripVlanCase extends ConvertorCase<StripVlanCase, Action, ActionResponseConvertorData> {
public OfToSalStripVlanCase() {
- super(StripVlanCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ super(StripVlanCase.class, true, OFConstants.OFP_VERSION_1_0);
}
@Override
*/
public class ActionResponseConvertorData extends ConvertorData {
private ActionPath actionPath;
+ private Short ipProtocol;
/**
* Instantiates a new Action response convertor data.
public void setActionPath(ActionPath actionPath) {
this.actionPath = actionPath;
}
+
+ /**
+ * Gets ip protocol.
+ *
+ * @return the ip protocol
+ */
+ public Short getIpProtocol() {
+ return ipProtocol;
+ }
+
+ /**
+ * Sets ip protocol.
+ *
+ * @param ipProtocol the ip protocol
+ */
+ public void setIpProtocol(final Short ipProtocol) {
+ this.ipProtocol = ipProtocol;
+ }
}
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
import org.opendaylight.openflowplugin.extension.api.AugmentTuple;
import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
-import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
import org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtensionHelper;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.FlowStatsResponseConvertorData;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
* Method wraps openflow 1.0 actions list to Apply Action Instructions
*
* @param actionsList list of action
+ * @param ipProtocol ip protocol
* @return OF10 actions as an instructions
*/
- private Instructions wrapOF10ActionsToInstruction(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> actionsList, final short version) {
+ private Instructions wrapOF10ActionsToInstruction(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> actionsList,
+ final short version,
+ final Short ipProtocol) {
ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(version);
actionResponseConvertorData.setActionPath(ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION);
+ actionResponseConvertorData.setIpProtocol(ipProtocol);
InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
List<Instruction> salInstructionList = new ArrayList<>();
salFlowStatsBuilder.setPriority(flowStats.getPriority());
salFlowStatsBuilder.setTableId(flowStats.getTableId());
+ Short ipProtocol = null;
+
if (flowStats.getMatchV10() != null) {
final Optional<MatchBuilder> matchBuilderOptional = getConvertorExecutor().convert(flowStats.getMatchV10(), data);
if (matchBuilderOptional.isPresent()) {
+ if (Objects.nonNull(matchBuilderOptional.get().getIpMatch())) {
+ ipProtocol = matchBuilderOptional.get().getIpMatch().getIpProtocol();
+ }
+
salFlowStatsBuilder.setMatch(matchBuilderOptional.get().build());
}
if (flowStats.getAction() != null && flowStats.getAction().size() != 0) {
- salFlowStatsBuilder.setInstructions(wrapOF10ActionsToInstruction(flowStats.getAction(), data.getVersion()));
+ salFlowStatsBuilder.setInstructions(wrapOF10ActionsToInstruction(flowStats.getAction(), data.getVersion(), ipProtocol));
}
}
actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());\r
actions.add(actionBuilder.build());\r
\r
+ // Add some unsupported actions and check if they are missing from results
actionBuilder = new ActionBuilder();\r
actionBuilder.setActionChoice(new SetNwDstCaseBuilder().build());\r
actions.add(actionBuilder.build());\r
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action\r
.Action> mdSalActions = mdSalActionsOptional.orElse(Collections.emptyList());\r
\r
- Assert.assertEquals("Wrong number of output actions", 18, mdSalActions.size());\r
+ Assert.assertEquals("Wrong number of output actions", 16, mdSalActions.size());
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = mdSalActions.get(0);\r
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"\r
+ ".rev131112.action.action.OutputActionCase", action.getImplementedInterface().getName());\r
action = mdSalActions.get(15);\r
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"\r
+ ".rev131112.action.action.PopPbbActionCase", action.getImplementedInterface().getName());\r
- action = mdSalActions.get(16);\r
- Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"\r
- + ".rev131112.action.action.SetNwDstActionCase", action.getImplementedInterface().getName());\r
- action = mdSalActions.get(17);\r
- Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"\r
- + ".rev131112.action.action.PopVlanActionCase", action.getImplementedInterface().getName());\r
}\r
\r
/**\r