X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=extension%2Fopenflowplugin-extension-nicira%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fextension%2Fvendor%2Fnicira%2Fconvertor%2Fmatch%2FRegConvertor.java;fp=extension%2Fopenflowplugin-extension-nicira%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fextension%2Fvendor%2Fnicira%2Fconvertor%2Fmatch%2FRegConvertor.java;h=48f2aa35e88d8971f6be6cecac6d93270f999326;hb=7aaaf315e33af8f0f290ba981c80727f567abff3;hp=e1d577ab0f839cfe694ee7e59f4b4240ad2c8529;hpb=4e543a5aed7a2dd2b5957d6d7f3a6d5ee1c81f66;p=openflowplugin.git diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/RegConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/RegConvertor.java index e1d577ab0f..48f2aa35e8 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/RegConvertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/RegConvertor.java @@ -1,24 +1,25 @@ /** * Copyright (c) 2014 Cisco Systems, Inc. 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.extension.vendor.nicira.convertor.match; +import com.google.common.base.Optional; import org.opendaylight.openflowjava.nx.NiciraMatchCodecs; import org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava; import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava; import org.opendaylight.openflowplugin.extension.api.ExtensionAugment; import org.opendaylight.openflowplugin.extension.api.path.MatchPath; import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.CodecPreconditionException; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxMatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.reg.grouping.RegValuesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.RegCaseValue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.RegCaseValueBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifPacketIn; @@ -42,13 +43,10 @@ import org.opendaylight.yangtools.yang.binding.Augmentation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Optional; - /** * @author msunal - * */ -public class RegConvertor implements ConvertorToOFJava, ConvertorFromOFJava { +public class RegConvertor implements ConvertorToOFJava, ConvertorFromOFJava { private final static Logger LOG = LoggerFactory.getLogger(RegConvertor.class); @@ -62,7 +60,7 @@ public class RegConvertor implements ConvertorToOFJava, ConvertorF */ @SuppressWarnings("unchecked") @Override - public ExtensionAugment> convert(MatchEntries input, MatchPath path) { + public ExtensionAugment> convert(MatchEntry input, MatchPath path) { NxmNxRegBuilder nxRegBuilder = new NxmNxRegBuilder(); if (!org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg.class .isAssignableFrom(input.getOxmMatchField())) { @@ -75,10 +73,11 @@ public class RegConvertor implements ConvertorToOFJava, ConvertorF nxRegBuilder .setReg((Class) input .getOxmMatchField()); - nxRegBuilder.setValue(input.getAugmentation(OfjAugNxMatch.class).getRegValues().getValue()); + RegCaseValue regCaseValue = ((RegCaseValue) input.getMatchEntryValue()); + nxRegBuilder.setValue(regCaseValue.getRegValues().getValue()); return resolveAugmentation(nxRegBuilder.build(), path, resolveRegKey(input.getOxmMatchField())); } - + private static Class resolveRegKey(Class oxmMatchField) { if (NiciraMatchCodecs.REG0_CODEC.getNxmField().isAssignableFrom(oxmMatchField)) { return NxmNxReg0Key.class; @@ -108,19 +107,19 @@ public class RegConvertor implements ConvertorToOFJava, ConvertorF } private static ExtensionAugment> resolveAugmentation(NxmNxReg nxmNxReg, - MatchPath path, Class key) { + MatchPath path, Class key) { switch (path) { - case FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH: - return new ExtensionAugment<>(NxAugMatchNotifUpdateFlowStats.class, - new NxAugMatchNotifUpdateFlowStatsBuilder().setNxmNxReg(nxmNxReg).build(), key); - case PACKETRECEIVED_MATCH: - return new ExtensionAugment<>(NxAugMatchNotifPacketIn.class, new NxAugMatchNotifPacketInBuilder() - .setNxmNxReg(nxmNxReg).build(), key); - case SWITCHFLOWREMOVED_MATCH: - return new ExtensionAugment<>(NxAugMatchNotifSwitchFlowRemoved.class, - new NxAugMatchNotifSwitchFlowRemovedBuilder().setNxmNxReg(nxmNxReg).build(), key); - default: - throw new CodecPreconditionException(path); + case FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH: + return new ExtensionAugment<>(NxAugMatchNotifUpdateFlowStats.class, + new NxAugMatchNotifUpdateFlowStatsBuilder().setNxmNxReg(nxmNxReg).build(), key); + case PACKETRECEIVED_MATCH: + return new ExtensionAugment<>(NxAugMatchNotifPacketIn.class, new NxAugMatchNotifPacketInBuilder() + .setNxmNxReg(nxmNxReg).build(), key); + case SWITCHFLOWREMOVED_MATCH: + return new ExtensionAugment<>(NxAugMatchNotifSwitchFlowRemoved.class, + new NxAugMatchNotifSwitchFlowRemovedBuilder().setNxmNxReg(nxmNxReg).build(), key); + default: + throw new CodecPreconditionException(path); } } @@ -134,15 +133,18 @@ public class RegConvertor implements ConvertorToOFJava, ConvertorF * .rev140714.general.extension.grouping.Extension) */ @Override - public MatchEntries convert(Extension extension) { + public MatchEntry convert(Extension extension) { Optional matchGrouping = MatchUtil.regResolver.getExtension(extension); if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); } NxmNxReg nxmNxReg = matchGrouping.get().getNxmNxReg(); RegValuesBuilder regValuesBuilder = new RegValuesBuilder().setValue(nxmNxReg.getValue()); - OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder().setRegValues(regValuesBuilder.build()); - return MatchUtil.createNiciraMatchEntries(Nxm1Class.class, nxmNxReg.getReg(), false, augNxMatchBuilder.build()); + RegCaseValueBuilder regCaseValueBuilder = new RegCaseValueBuilder(); + regCaseValueBuilder.setRegValues(regValuesBuilder.build()); + return MatchUtil.createDefaultMatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg.class, + Nxm1Class.class, + regCaseValueBuilder.build()).build(); } }