<sal.version>0.10.0-SNAPSHOT</sal.version>
<switchmanager.api.version>0.9.0-SNAPSHOT</switchmanager.api.version>
<yangtools.version>0.8.0-SNAPSHOT</yangtools.version>
- <!-- 3rd Pary Dependency Versions -->
- <commons.collection.version>1.0</commons.collection.version>
- <httpcomponents.version>4.2.1</httpcomponents.version>
- <portlet.version>2.0</portlet.version>
+ <!-- 3rd Party Dependency Versions -->
<powermock.version>1.5.2</powermock.version>
<dlux.version>0.3.0-SNAPSHOT</dlux.version>
<ovsdb.ui.version>0.1.0-SNAPSHOT</ovsdb.ui.version>
<type>pom</type>
<scope>import</scope>
</dependency>
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>${commons.collection.version}</version>
- </dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>${netty.version}</version>
</dependency>
- <dependency>
- <groupId>javax.portlet</groupId>
- <artifactId>portlet-api</artifactId>
- <version>${portlet.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore-nio</artifactId>
- <version>${httpcomponents.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>commons.northbound</artifactId>
- <version>${northbound.commons.version}</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-api</artifactId>
<version>${controller.config.version}</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>containermanager</artifactId>
- <version>${containermanager.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>forwardingrulesmanager</artifactId>
- <version>${forwardingrulesmanager.version}</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.neutron</groupId>
<artifactId>neutron-spi</artifactId>
<version>1.6.0-SNAPSHOT</version>
<type>zip</type>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal</artifactId>
- <version>${sal.version}</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<scope>import</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>switchmanager</artifactId>
- <version>${switchmanager.api.version}</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.openflowplugin.model</groupId>
<artifactId>model-flow-base</artifactId>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>features-parent</artifactId>
<version>1.6.0-SNAPSHOT</version>
- <relativePath></relativePath>
+ <relativePath/>
</parent>
<groupId>org.opendaylight.ovsdb</groupId>
<properties>
<odl.karaf.base.version>1.6.0-SNAPSHOT</odl.karaf.base.version>
<mdsal.version>1.3.0-SNAPSHOT</mdsal.version>
- <io.netty.version>3.8.0.Final</io.netty.version>
<networkconfig.neutron.version>0.6.0-SNAPSHOT</networkconfig.neutron.version>
<ovsdb.library.version>1.2.1-SNAPSHOT</ovsdb.library.version>
<openstack.netvirt.version>1.2.1-SNAPSHOT</openstack.netvirt.version>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
- <version>${commons.lang3.version}</version>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty</artifactId>
- <version>${io.netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
- <version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
- <version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
- <version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
- <version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
- <version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
- <version>${netty.version}</version>
</dependency>
<dependency>
<groupId>equinoxSDK381</groupId>
<artifactId>javax.servlet</artifactId>
- <version>3.0.0.v201112011016</version>
</dependency>
<dependency>
<groupId>equinoxSDK381</groupId>
<artifactId>javax.servlet.jsp</artifactId>
- <version>2.2.0.v201112011158</version>
</dependency>
<dependency>
<groupId>equinoxSDK381</groupId>
<artifactId>utils.servicehelper</artifactId>
<version>${ovsdb.utils.servicehelper.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>utils.mdsal-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<classifier>features</classifier>
<type>xml</type>
</dependency>
- <dependency>
- <groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>ovsdb-ui-bundle</artifactId>
- <version>${ovsdb.ui.version}</version>
- </dependency>
</dependencies>
</project>
<features name="ovsdb-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
- <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin-extension/${openflowplugin.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin/${openflowplugin.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.neutron/features-neutron/${networkconfig.neutron.version}/xml/features</repository>
+ <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin-extension/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.neutron/features-neutron/{{VERSION}}/xml/features</repository>
<repository>mvn:org.opendaylight.ovsdb/southbound-features/1.2.1-SNAPSHOT/xml/features</repository>
- <repository>mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.ovsdb/library-features/${ovsdb.library.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.dlux/features-dlux/${dlux.version}/xml/features</repository>
+ <repository>mvn:org.opendaylight.controller/features-mdsal/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.ovsdb/library-features/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.dlux/features-dlux/{{VERSION}}/xml/features</repository>
<feature name="odl-ovsdb-all" description="OpenDaylight :: OVSDB :: all"
version='${project.version}'>
<feature name="odl-ovsdb-schema-openvswitch" description="OVSDB :: Schema :: Open_vSwitch"
version='${schema.openvswitch.version}'>
<feature version="${ovsdb.library.version}">odl-ovsdb-library</feature>
- <bundle>mvn:org.opendaylight.ovsdb/schema.openvswitch/${schema.openvswitch.version}</bundle>
+ <bundle>mvn:org.opendaylight.ovsdb/schema.openvswitch/{{VERSION}}</bundle>
</feature>
<feature name="odl-ovsdb-schema-hardwarevtep" description="OVSDB :: Schema :: hardware_vtep"
version='${schema.hardwarevtep.version}'>
<feature version="${ovsdb.library.version}">odl-ovsdb-library</feature>
- <bundle>mvn:org.opendaylight.ovsdb/schema.hardwarevtep/${schema.hardwarevtep.version}</bundle>
+ <bundle>mvn:org.opendaylight.ovsdb/schema.hardwarevtep/{{VERSION}}</bundle>
</feature>
<feature name="odl-ovsdb-openstack" description="OpenDaylight :: OVSDB :: OpenStack Network Virtualization"
<feature version='${mdsal.version}'>odl-mdsal-broker</feature>
<feature version="${openflowplugin.version}">odl-openflowplugin-nsf-model</feature>
<feature version="${networkconfig.neutron.version}">odl-neutron-service</feature>
- <feature version="1.2.1-SNAPSHOT">odl-ovsdb-southbound-impl-ui</feature>
+ <feature version="${project.version}">odl-ovsdb-southbound-impl-ui</feature>
<feature version="${openflowplugin.version}">odl-openflowplugin-flow-services</feature>
<feature version="${openflowplugin.version}">odl-openflowplugin-nxm-extensions</feature>
- <bundle>mvn:org.opendaylight.ovsdb/utils.servicehelper/${ovsdb.utils.servicehelper.version}</bundle>
- <bundle>mvn:org.opendaylight.ovsdb/openstack.net-virt/${openstack.netvirt.version}</bundle>
- <bundle>mvn:org.opendaylight.ovsdb/openstack.net-virt-providers/${openstack.netvirt.providers.version}</bundle>
- <bundle>mvn:org.opendaylight.neutron/dummyprovider/${networkconfig.neutron.version}</bundle>
- <configfile finalname="etc/opendaylight/karaf/netvirt-impl-default-config.xml">mvn:org.opendaylight.ovsdb/openstack.net-virt/${project.version}/xml/config</configfile>
- <configfile finalname="etc/opendaylight/karaf/netvirt-providers-impl-default-config.xml">mvn:org.opendaylight.ovsdb/openstack.net-virt-providers/${project.version}/xml/config</configfile>
+ <bundle>mvn:org.opendaylight.ovsdb/utils.servicehelper/{{VERSION}}</bundle>
+ <bundle>mvn:org.opendaylight.ovsdb/utils.mdsal-utils/{{VERSION}}</bundle>
+ <bundle>mvn:org.opendaylight.ovsdb/openstack.net-virt/{{VERSION}}</bundle>
+ <bundle>mvn:org.opendaylight.ovsdb/openstack.net-virt-providers/{{VERSION}}</bundle>
+ <bundle>mvn:org.opendaylight.neutron/dummyprovider/{{VERSION}}</bundle>
+ <configfile finalname="etc/opendaylight/karaf/netvirt-impl-default-config.xml">mvn:org.opendaylight.ovsdb/openstack.net-virt/{{VERSION}}/xml/config</configfile>
+ <configfile finalname="etc/opendaylight/karaf/netvirt-providers-impl-default-config.xml">mvn:org.opendaylight.ovsdb/openstack.net-virt-providers/{{VERSION}}/xml/config</configfile>
</feature>
<feature name="odl-ovsdb-ui" description="OpenDaylight :: OVSDB :: DLUX Integration Plugin" version='${ovsdb.ui.version}'>
<feature version="${dlux.version}">odl-dlux-core</feature>
- <bundle>mvn:org.opendaylight.ovsdb/ovsdb-ui-bundle/${ovsdb.ui.version}</bundle>
+ <bundle>mvn:org.opendaylight.ovsdb/ovsdb-ui-bundle/{{VERSION}}</bundle>
</feature>
</features>
*/
package org.opendaylight.ovsdb.openstack.netvirt.it;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.ops4j.pax.exam.CoreOptions.composite;
import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.vmOption;
import static org.ops4j.pax.exam.CoreOptions.when;
+import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
+import static org.ops4j.pax.exam.MavenUtils.asInProject;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.Lists;
-import com.google.common.collect.ObjectArrays;
import java.io.File;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.inject.Inject;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
+import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager;
import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.AbstractServiceInstance;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.PipelineOrchestrator;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
+import org.opendaylight.ovsdb.utils.mdsal.openflow.FlowUtils;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.*;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeExternalIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeOtherConfigs;
private Option[] getOtherOptions() {
return new Option[] {
+ wrappedBundle(
+ mavenBundle("org.opendaylight.ovsdb", "utils.mdsal-openflow")
+ .version(asInProject())
+ .type("jar")),
vmOption("-javaagent:../jars/org.jacoco.agent.jar=destfile=../../jacoco-it.exec"),
keepRuntimeFolder()
};
@Override
public String getModuleName() {
- return "openstack.net-virt-providers";
+ return "netvirt-providers-impl";
}
@Override
public String getInstanceName() {
- return "net-virt-providers-default";
+ return "netvirt-providers-default";
}
@Override
return composite(
editConfigurationFilePut(NetvirtITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
"log4j.logger.org.opendaylight.ovsdb",
- LogLevelOption.LogLevel.DEBUG.name()),
+ LogLevelOption.LogLevel.TRACE.name()),
editConfigurationFilePut(NetvirtITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
"log4j.logger.org.opendaylight.ovsdb.lib",
LogLevelOption.LogLevel.INFO.name()),
super.getLoggingOption());
- /*editConfigurationFilePut(NetvirtITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
- "log4j.logger.org.opendaylight.ovsdb.openstack.net-virt",
- LogLevelOption.LogLevel.DEBUG.name())*/
}
private Option[] getPropertiesOptions() {
LOG.info("getPropertiesOptions: Using the following properties: mode= {}, ip:port= {}:{}",
connectionType, addressStr, portStr);
- Option[] options = new Option[] {
+ return new Option[] {
editConfigurationFilePut(NetvirtITConstants.CUSTOM_PROPERTIES,
NetvirtITConstants.SERVER_IPADDRESS, addressStr),
editConfigurationFilePut(NetvirtITConstants.CUSTOM_PROPERTIES,
editConfigurationFilePut(NetvirtITConstants.CUSTOM_PROPERTIES,
NetvirtITConstants.CONNECTION_TYPE, connectionType),
};
- return options;
}
@Before
}
private Node getOvsdbNode(final ConnectionInfo connectionInfo) {
- Node node = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL,
+ return mdsalUtils.read(LogicalDatastoreType.OPERATIONAL,
SouthboundMapper.createInstanceIdentifier(connectionInfo));
- return node;
}
private boolean deleteOvsdbNode(final ConnectionInfo connectionInfo) throws InterruptedException {
try{
for (Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces();
ifaces.hasMoreElements();) {
- NetworkInterface iface = (NetworkInterface) ifaces.nextElement();
+ NetworkInterface iface = ifaces.nextElement();
for (Enumeration<InetAddress> inetAddrs = iface.getInetAddresses(); inetAddrs.hasMoreElements();) {
- InetAddress inetAddr = (InetAddress) inetAddrs.nextElement();
+ InetAddress inetAddr = inetAddrs.nextElement();
if (!inetAddr.isLoopbackAddress()) {
if (inetAddr.isSiteLocalAddress()) {
ipaddress = inetAddr.getHostAddress();
}
private List<ProtocolEntry> createMdsalProtocols() {
- List<ProtocolEntry> protocolList = new ArrayList<ProtocolEntry>();
+ List<ProtocolEntry> protocolList = new ArrayList<>();
ImmutableBiMap<String, Class<? extends OvsdbBridgeProtocolBase>> mapper =
SouthboundConstants.OVSDB_PROTOCOL_MAP.inverse();
protocolList.add(new ProtocolEntryBuilder().
- setProtocol((Class<? extends OvsdbBridgeProtocolBase>) mapper.get("OpenFlow13")).build());
+ setProtocol(mapper.get("OpenFlow13")).build());
return protocolList;
}
@Test
public void testNetVirt() throws InterruptedException {
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portStr);
- connectOvsdbNode(connectionInfo);
+ Node ovsdbNode = connectOvsdbNode(connectionInfo);
+
Thread.sleep(10000);
+ // Verify the pipeline flows were installed
+ PipelineOrchestrator pipelineOrchestrator =
+ (PipelineOrchestrator) ServiceHelper.getGlobalInstance(PipelineOrchestrator.class, this);
+ assertNotNull("Could not find PipelineOrchestrator Service", pipelineOrchestrator);
+ Node bridgeNode = southbound.getBridgeNode(ovsdbNode, NetvirtITConstants.INTEGRATION_BRIDGE_NAME);
+ assertNotNull("bridge " + NetvirtITConstants.INTEGRATION_BRIDGE_NAME + " was not found", bridgeNode);
+ long datapathId = southbound.getDataPathId(bridgeNode);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder nodeBuilder =
+ FlowUtils.createNodeBuilder(datapathId);
+
+ List<Service> staticPipeline = pipelineOrchestrator.getStaticPipeline();
+ List<Service> staticPipelineFound = Lists.newArrayList();
+ for (Service service : pipelineOrchestrator.getServiceRegistry().keySet()) {
+ if (staticPipeline.contains(service)) {
+ staticPipelineFound.add(service);
+ }
+ FlowBuilder flowBuilder = FlowUtils.getPipelineFlow(service.getTable(), (short)0);
+ Flow flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.CONFIGURATION);
+ assertNotNull("Could not find flow in config", flow);
+ flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.OPERATIONAL);
+ assertNotNull("Could not find flow in operational", flow);
+ }
+ assertEquals("did not find all expected flows in static pipeline",
+ staticPipeline.size(), staticPipelineFound.size());
+
netVirtAddPort(connectionInfo);
Thread.sleep(10000);
Assert.assertTrue(deleteBridge(connectionInfo, NetvirtITConstants.INTEGRATION_BRIDGE_NAME));
LOG.info(">>>>> node: {}", node);
}
}
+
+ private Flow getFlow (
+ FlowBuilder flowBuilder,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder nodeBuilder,
+ LogicalDatastoreType store)
+ throws InterruptedException {
+
+ Flow flow = null;
+ for (int i = 0; i < 10; i++) {
+ flow = FlowUtils.getFlow(flowBuilder, nodeBuilder, dataBroker.newReadOnlyTransaction(), store);
+ if (flow != null) {
+ LOG.info("getFlow: flow({}): {}", store, flow);
+ break;
+ }
+ Thread.sleep(1000);
+ }
+ return flow;
+ }
}
.build();
public static final String IID_EXTERNAL_ID_KEY = "opendaylight-iid";
- public static enum VLANMODES {
+ public enum VLANMODES {
ACCESS("access"),
NATIVE_TAGGED("native-tagged"),
NATIVE_UNTAGGED("native-untagged"),
private final String mode;
- private VLANMODES(String mode) {
+ VLANMODES(String mode) {
this.mode = mode;
}
@Override
public static String createDatapathType(OvsdbBridgeAugmentation mdsalbridge) {
String datapathtype = SouthboundConstants.DATAPATH_TYPE_MAP.get(DatapathTypeSystem.class);
- if (mdsalbridge.getDatapathType() != null) {
- if (SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType()) != null) {
- datapathtype = SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType());
- } else {
- throw new IllegalArgumentException("Unknown datapath type "
- + SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType()));
+ if (mdsalbridge.getDatapathType() != null && !mdsalbridge.getDatapathType().equals(DatapathTypeBase.class)) {
+ datapathtype = SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType());
+ if (datapathtype == null) {
+ throw new IllegalArgumentException("Unknown datapath type " + mdsalbridge.getDatapathType().getName());
}
}
return datapathtype;
}
public static Set<String> createOvsdbBridgeProtocols(OvsdbBridgeAugmentation ovsdbBridgeNode) {
- Set<String> protocols = new HashSet<String>();
+ Set<String> protocols = new HashSet<>();
if (ovsdbBridgeNode.getProtocolEntry() != null && ovsdbBridgeNode.getProtocolEntry().size() > 0) {
for (ProtocolEntry protocol : ovsdbBridgeNode.getProtocolEntry()) {
if (SouthboundConstants.OVSDB_PROTOCOL_MAP.get(protocol.getProtocol()) != null) {
<Embed-Dependency>utils.config,utils.mdsal-openflow;type=!pom;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Export-Package>
- org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.*
+ org.opendaylight.ovsdb.openstack.netvirt.providers,
+ org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13
</Export-Package>
</instructions>
</configuration>
<snapshot>
<required-capabilities>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability>
- <!--<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28</capability>
- <capability>
- urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28
- </capability>
- <capability>
- urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28
- </capability>
- <capability>
- urn:opendaylight:params:xml:ns:yang:controller:config?module=config&revision=2013-04-05
- </capability>-->
<capability>urn:opendaylight:params:xml:ns:yang:southbound:impl?module=southbound-impl&revision=2014-12-10</capability>
<capability>urn:opendaylight:params:xml:ns:yang:netvirt:impl?module=netvirt-impl&revision=2015-05-13</capability>
<capability>urn:opendaylight:params:xml:ns:yang:netvirt:providers:impl?module=netvirt-providers-impl&revision=2015-05-13</capability>
public class ConfigActivator implements BundleActivator {
private static final Logger LOG = LoggerFactory.getLogger(ConfigActivator.class);
- private List<ServiceRegistration<?>> registrations = new ArrayList<ServiceRegistration<?>>();
+ private List<ServiceRegistration<?>> registrations = new ArrayList<>();
private ProviderContext providerContext;
public ConfigActivator(ProviderContext providerContext) {
@Override
public void close() throws Exception {
+ LOG.info("NetvirtProvidersProvider closed");
activator.stop(bundleContext);
}
return;
}
}
- ingressAclProvider.programFixedSecurityAcl(dpid, segmentationId, dhcpPort.getMacAddress(), localPort,
+ ingressAclProvider.programFixedSecurityGroup(dpid, segmentationId, dhcpPort.getMacAddress(), localPort,
isLastPortinSubnet, isComputePort, write);
- egressAclProvider.programFixedSecurityAcl(dpid, segmentationId, attachedMac, localPort,
+ egressAclProvider.programFixedSecurityGroup(dpid, segmentationId, attachedMac, localPort,
srcAddressList, isLastPortinBridge, isComputePort,write);
/* If the network type is tunnel based (VXLAN/GRRE/etc) with Neutron Port Security ACLs */
/* TODO SB_MIGRATION */
//Associate the security group flows.
List<NeutronSecurityGroup> securityGroupListInPort = securityServicesManager
.getSecurityGroupInPortList(intf);
+ String neutronPortId = southbound.getInterfaceExternalIdsValue(intf,
+ Constants.EXTERNAL_ID_INTERFACE_ID);
for (NeutronSecurityGroup securityGroupInPort:securityGroupListInPort) {
- ingressAclProvider.programPortSecurityAcl(dpid, segmentationId, attachedMac, localPort,
- securityGroupInPort,srcAddressList, write);
- egressAclProvider.programPortSecurityAcl(dpid, segmentationId, attachedMac, localPort,
- securityGroupInPort,srcAddressList, write);
+ ingressAclProvider.programPortSecurityGroup(dpid, segmentationId, attachedMac, localPort,
+ securityGroupInPort, neutronPortId, write);
+ egressAclProvider.programPortSecurityGroup(dpid, segmentationId, attachedMac, localPort,
+ securityGroupInPort, neutronPortId, write);
}
}
} else {
package org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13;
+import java.util.List;
+import java.util.Map;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.osgi.framework.ServiceReference;
public interface PipelineOrchestrator {
Service getNextServiceInPipeline(Service service);
AbstractServiceInstance getServiceInstance(Service service);
+ Map<Service, AbstractServiceInstance> getServiceRegistry();
+ List<Service> getStaticPipeline();
void enqueue(Node node);
void registerService(final ServiceReference ref, AbstractServiceInstance serviceInstance);
void unregisterService(final ServiceReference ref);
package org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
public class PipelineOrchestratorImpl implements ConfigInterface, NodeCacheListener, PipelineOrchestrator {
private static final Logger LOG = LoggerFactory.getLogger(PipelineOrchestratorImpl.class);
+
+ public List<Service> getStaticPipeline() {
+ return staticPipeline;
+ }
+
private List<Service> staticPipeline = Lists.newArrayList(
Service.CLASSIFIER,
Service.ARP_RESPONDER,
Service.OUTBOUND_NAT,
Service.L2_FORWARDING
);
+
+ public Map<Service, AbstractServiceInstance> getServiceRegistry() {
+ return serviceRegistry;
+ }
+
Map<Service, AbstractServiceInstance> serviceRegistry = Maps.newConcurrentMap();
private volatile BlockingQueue<Node> queue;
private ExecutorService eventHandler;
Service service = (Service)ref.getProperty(AbstractServiceInstance.SERVICE_PROPERTY);
LOG.info("registerService {} - {}", serviceInstance, service);
serviceRegistry.put(service, serviceInstance);
+ // insert the service if not already there. The list is ordered based of table ID.
+ if (!staticPipeline.contains(service) && !isTableInPipeline(service.getTable())) {
+ staticPipeline.add(service);
+ Collections.sort(staticPipeline, Service.insertComparator);
+ }
+ LOG.info("registerService: {}", staticPipeline);
+ }
+
+ private boolean isTableInPipeline (short tableId) {
+ boolean found = false;
+ for (Service service : staticPipeline) {
+ if (service.getTable() == tableId) {
+ found = true;
+ break;
+ }
+ }
+ return found;
}
public void unregisterService(final ServiceReference ref) {
package org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13;
+import java.util.Comparator;
+
public enum Service {
CLASSIFIER ((short) 0, "Classifier"),
GATEWAY_RESOLVER((short) 0, "External Network Gateway Resolver"),
DIRECTOR ((short) 10, "Director"),
+ SFC_CLASSIFIER ((short) 10, "SFC Classifier"),
ARP_RESPONDER ((short) 20, "Distributed ARP Responder"),
INBOUND_NAT ((short) 30, "DNAT for inbound floating-ip traffic"),
EGRESS_ACL ((short) 40, "Egress Acces-control"),
short table;
String description;
- private Service (short table, String description) {
+ Service(short table, String description) {
this.table = table;
this.description = description;
}
public String getDescription() {
return description;
}
+
+ public static Comparator<Service> insertComparator = new Comparator<Service>() {
+
+ @Override
+ public int compare(Service service1, Service service2) {
+ return service1.getTable() - service2.getTable();
+ }
+ };
}
BigInteger.valueOf(REG_VALUE_FROM_LOCAL)));
ab.setOrder(1);
ab.setKey(new ActionKey(1));
+
actionList.add(ab.build());
ib.setOrder(0);
package org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.services;
-import java.math.BigInteger;
-import java.util.List;
+import com.google.common.collect.Lists;
-import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
-import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
-import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
import org.opendaylight.ovsdb.openstack.netvirt.api.EgressAclProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityGroupCacheManger;
import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager;
import org.opendaylight.ovsdb.openstack.netvirt.providers.ConfigInterface;
import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.AbstractServiceInstance;
import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
import org.opendaylight.ovsdb.utils.mdsal.openflow.InstructionUtils;
import org.opendaylight.ovsdb.utils.mdsal.openflow.MatchUtils;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.Lists;
+import java.math.BigInteger;
+import java.util.List;
public class EgressAclService extends AbstractServiceInstance implements EgressAclProvider, ConfigInterface {
private static final Logger LOG = LoggerFactory.getLogger(EgressAclService.class);
private volatile SecurityServicesManager securityServicesManager;
+ private volatile SecurityGroupCacheManger securityGroupCacheManger;
private static final int DHCP_SOURCE_PORT = 67;
private static final int DHCP_DESTINATION_PORT = 68;
private static final String HOST_MASK = "/32";
}
@Override
- public void programPortSecurityAcl(Long dpid, String segmentationId, String attachedMac, long localPort,
- NeutronSecurityGroup securityGroup,
- List<Neutron_IPs> srcAddressList, boolean write) {
+ public void programPortSecurityGroup(Long dpid, String segmentationId, String attachedMac, long localPort,
+ NeutronSecurityGroup securityGroup, String portUuid, boolean write) {
- LOG.trace("programPortSecurityAcl: neutronSecurityGroup: {} ", securityGroup);
+ LOG.trace("programPortSecurityGroup: neutronSecurityGroup: {} ", securityGroup);
if (securityGroup == null || securityGroup.getSecurityRules() == null) {
return;
}
List<NeutronSecurityRule> portSecurityList = securityGroup.getSecurityRules();
/* Iterate over the Port Security Rules in the Port Security Group bound to the port*/
for (NeutronSecurityRule portSecurityRule : portSecurityList) {
+
/**
* Neutron Port Security Acl "egress" and "IPv4"
* Check that the base conditions for flow based Port Security are true:
* http://docs.openstack.org/api/openstack-network/2.0/content/security_groups.html
*
*/
+
+ if (portSecurityRule == null ||
+ portSecurityRule.getSecurityRuleEthertype() == null ||
+ portSecurityRule.getSecurityRuleDirection() == null) {
+ continue;
+ }
+
if ("IPv4".equals(portSecurityRule.getSecurityRuleEthertype())
&& portSecurityRule.getSecurityRuleDirection().equals("egress")) {
- LOG.debug("programPortSecurityAcl: Acl Rule matching IPv4 and ingress is: {} ", portSecurityRule);
- if (null == portSecurityRule.getSecurityRuleProtocol()) {
- /* TODO Rework on the priority values */
- egressAclIPv4(dpid, segmentationId, attachedMac,
- write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- } else if (null != portSecurityRule.getSecurityRemoteGroupID()) {
- //Remote Security group is selected
+ LOG.debug("programPortSecurityGroup: Acl Rule matching IPv4 and ingress is: {} ", portSecurityRule);
+ if (null != portSecurityRule.getSecurityRemoteGroupID()) {
+ //Remote Security group is selected
List<Neutron_IPs> remoteSrcAddressList = securityServicesManager
- .getVmListForSecurityGroup(srcAddressList,portSecurityRule.getSecurityRemoteGroupID());
+ .getVmListForSecurityGroup(portUuid,portSecurityRule.getSecurityRemoteGroupID());
if (null != remoteSrcAddressList) {
for (Neutron_IPs vmIp :remoteSrcAddressList ) {
- switch (portSecurityRule.getSecurityRuleProtocol()) {
- case MatchUtils.TCP:
- egressAclTcp(dpid, segmentationId, attachedMac,
- portSecurityRule,vmIp.getIpAddress(), write,
- Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- break;
- case MatchUtils.UDP:
- egressAclUdp(dpid, segmentationId, attachedMac,
- portSecurityRule,vmIp.getIpAddress(), write,
- Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- break;
- case MatchUtils.ICMP:
- egressAclIcmp(dpid, segmentationId, attachedMac,
- portSecurityRule, vmIp.getIpAddress(),write,
- Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- break;
- default:
- LOG.error("programPortSecurityAcl: Protocol not supported", portSecurityRule);
- break;
- }
+
+ programPortSecurityRule(dpid, segmentationId, attachedMac,
+ localPort, portSecurityRule, vmIp, write);
+ }
+ if (write) {
+ securityGroupCacheManger.addToCache(portSecurityRule.getSecurityRemoteGroupID(), portUuid);
+ } else {
+ securityGroupCacheManger.removeFromCache(portSecurityRule.getSecurityRemoteGroupID(),
+ portUuid);
}
}
} else {
- //CIDR is selected
- switch (portSecurityRule.getSecurityRuleProtocol()) {
- case MatchUtils.TCP:
- egressAclTcp(dpid, segmentationId, attachedMac,
- portSecurityRule, null, write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- break;
- case MatchUtils.UDP:
- egressAclUdp(dpid, segmentationId, attachedMac,
- portSecurityRule, null, write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- break;
- case MatchUtils.ICMP:
- egressAclIcmp(dpid, segmentationId, attachedMac,
- portSecurityRule, null, write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- break;
- default:
- LOG.error("programPortSecurityAcl: Protocol not supported", portSecurityRule);
- }
- }
- }
- /*
- * Code is refactored to handle all the protocols. More
- * protocols will be added incrementrally
- * TODO Connection tracking will be used to track active TCP connections This code
- * may be reused then.
- */
- /* if (portSecurityRule.getSecurityRuleEthertype().equalsIgnoreCase("IPv4") &&
- portSecurityRule.getSecurityRuleDirection().equalsIgnoreCase("egress")) {
- LOG.debug("Egress IPV4 ACL Port Security Rule: {} ", portSecurityRule);
- // ToDo: Implement Port Range
-
- *//**
- * TCP Proto (True), TCP Port Minimum (True), TCP Port Max (True), IP Prefix (True)
- *//*
- if (String.valueOf(portSecurityRule.getSecurityRuleProtocol()).equalsIgnoreCase("tcp") &&
- !String.valueOf(portSecurityRule.getSecurityRulePortMin()).equalsIgnoreCase("null") &&
- !String.valueOf(portSecurityRule.getSecurityRulePortMax()).equalsIgnoreCase("null") &&
- (!String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix()).equalsIgnoreCase("null") &&
- !String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix())
- .equalsIgnoreCase("0.0.0.0/0"))) {
- LOG.debug(
- "Rule #1 egress PortSec Rule Matches -> TCP Protocol: {}, TCP Port Min: {}, TCP Port Max: {}, IP Prefix: {}",
- portSecurityRule.getSecurityRuleProtocol(), portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRulePortMax(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix());
- egressACLDefaultTcpDrop(dpid, segmentationId, attachedMac,
- Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY_DROP,
- true);
- egressACLTcpPortWithPrefix(dpid, segmentationId,
- attachedMac, true, portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix(),
- Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- continue;
- }
- *//**
- * TCP Proto (True), TCP Port Minimum (True), TCP Port Max (False), IP Prefix (True)
- *//*
- if (String.valueOf(portSecurityRule.getSecurityRuleProtocol()).equalsIgnoreCase("tcp") &&
- !String.valueOf(portSecurityRule.getSecurityRulePortMin()).equalsIgnoreCase("null") &&
- String.valueOf(portSecurityRule.getSecurityRulePortMax()).equalsIgnoreCase("null") &&
- (!String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix()).equalsIgnoreCase("null") &&
- !String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix())
- .equalsIgnoreCase("0.0.0.0/0"))) {
- LOG.debug(
- "Rule #2 egress PortSec Rule Matches -> TCP Protocol: {}, TCP Port Min: {}, TCP Port Max: {}, IP Prefix: {}",
- portSecurityRule.getSecurityRuleProtocol(), portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRulePortMax(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix());
- egressACLDefaultTcpDrop(dpid, segmentationId, attachedMac,
- Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY_DROP,
- true);
- egressACLTcpPortWithPrefix(dpid, segmentationId,
- attachedMac, true, portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix(),
- Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- continue;
+ programPortSecurityRule(dpid, segmentationId, attachedMac, localPort,
+ portSecurityRule, null, write);
}
- *//**
- * TCP Proto (True), TCP Port Minimum (False), TCP Port Max (False), IP Prefix (True)
- *//*
- if (String.valueOf(portSecurityRule.getSecurityRuleProtocol()).equalsIgnoreCase("tcp") &&
- String.valueOf(portSecurityRule.getSecurityRulePortMin()).equalsIgnoreCase("null") &&
- String.valueOf(portSecurityRule.getSecurityRulePortMax()).equalsIgnoreCase("null") &&
- !String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix()).equalsIgnoreCase("null")) {
- LOG.debug(
- "Rule #3 egress PortSec Rule Matches -> TCP Protocol: {}, TCP Port Min: {}, TCP Port Max: {}, IP Prefix: {}",
- portSecurityRule.getSecurityRuleProtocol(), portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRulePortMax(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix());
- egressACLDefaultTcpDrop(dpid, segmentationId, attachedMac, Constants.PROTO_PREFIX_MATCH_PRIORITY_DROP,
- true);
- egressACLPermitAllProto(dpid, segmentationId, attachedMac, true,
- portSecurityRule.getSecurityRuleRemoteIpPrefix(), Constants.PROTO_PREFIX_MATCH_PRIORITY);
- continue;
- }
- *//**
- * TCP Proto (False), TCP Port Minimum (False), TCP Port Max (False), IP Prefix (True)
- *//*
- if (String.valueOf(portSecurityRule.getSecurityRuleProtocol()).equalsIgnoreCase("null") &&
- String.valueOf(portSecurityRule.getSecurityRulePortMin()).equalsIgnoreCase("null") &&
- String.valueOf(portSecurityRule.getSecurityRulePortMin()).equalsIgnoreCase("null") &&
- (!String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix()).equalsIgnoreCase("null") &&
- !String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix())
- .equalsIgnoreCase("0.0.0.0/0"))) {
- LOG.debug(
- "Rule #4 egress PortSec Rule Matches -> TCP Protocol: {}, TCP Port Min: {}, TCP Port Max: {}, IP Prefix: {}",
- portSecurityRule.getSecurityRuleProtocol(), portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRulePortMax(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix());
- egressACLDefaultTcpDrop(dpid, segmentationId, attachedMac, Constants.PREFIX_MATCH_PRIORITY_DROP, true);
- egressACLPermitAllProto(dpid, segmentationId, attachedMac, true,
- portSecurityRule.getSecurityRuleRemoteIpPrefix(), Constants.PREFIX_MATCH_PRIORITY);
- continue;
- }
- *//**
- * TCP Proto (True), TCP Port Minimum (True), TCP Port Max (True), IP Prefix (False)
- *//*
- if (String.valueOf(portSecurityRule.getSecurityRuleProtocol()).equalsIgnoreCase("tcp") &&
- !String.valueOf(portSecurityRule.getSecurityRulePortMin()).equalsIgnoreCase("null") &&
- !String.valueOf(portSecurityRule.getSecurityRulePortMax()).equalsIgnoreCase("null") &&
- String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix()).equalsIgnoreCase("null")) {
- LOG.debug(
- "Rule #5 egress PortSec Rule Matches -> TCP Protocol: {}, TCP Port Min: {}, TCP Port Max: {}, IP Prefix: {}",
- portSecurityRule.getSecurityRuleProtocol(), portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRulePortMax(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix());
- egressACLDefaultTcpDrop(dpid, segmentationId, attachedMac, Constants.PROTO_PORT_MATCH_PRIORITY_DROP,
- true);
- egressACLTcpSyn(dpid, segmentationId,
- attachedMac, true, portSecurityRule.getSecurityRulePortMin(),
- Constants.PROTO_PORT_MATCH_PRIORITY);
- continue;
- }
- *//**
- * TCP Proto (True), TCP Port Minimum (True), TCP Port Max (False), IP Prefix (False)
- *//*
- if (String.valueOf(portSecurityRule.getSecurityRuleProtocol()).equalsIgnoreCase("tcp") &&
- !String.valueOf(portSecurityRule.getSecurityRulePortMin()).equalsIgnoreCase("null") &&
- String.valueOf(portSecurityRule.getSecurityRulePortMax()).equalsIgnoreCase("null") &&
- String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix()).equalsIgnoreCase("null")) {
- LOG.debug(
- "Rule #6 egress PortSec Rule Matches -> TCP Protocol: {}, TCP Port Min: {}, TCP Port Max: {}, IP Prefix: {}",
- portSecurityRule.getSecurityRuleProtocol(), portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRulePortMax(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix());
- egressACLDefaultTcpDrop(dpid, segmentationId, attachedMac,
- Constants.PROTO_PORT_MATCH_PRIORITY_DROP, true);
- egressACLTcpSyn(dpid, segmentationId, attachedMac, true,
- portSecurityRule.getSecurityRulePortMin(), Constants.PROTO_PORT_MATCH_PRIORITY);
- continue;
- }
- *//**
- * TCP Proto (True), TCP Port Minimum (False), TCP Port Max (False), IP Prefix (False or 0.0.0.0/0)
- *//*
- if (String.valueOf(portSecurityRule.getSecurityRuleProtocol()).equalsIgnoreCase("tcp") &&
- String.valueOf(portSecurityRule.getSecurityRulePortMin()).equalsIgnoreCase("null") &&
- String.valueOf(portSecurityRule.getSecurityRulePortMax()).equalsIgnoreCase("null") &&
- ((String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix()).equalsIgnoreCase("null")) ||
- String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix())
- .equalsIgnoreCase("0.0.0.0/0"))) {
- LOG.debug(
- "Rule #7 egress PortSec Rule Matches -> TCP Protocol: {}, TCP Port Min: {}, TCP Port Max: {}, IP Prefix: {}",
- portSecurityRule.getSecurityRuleProtocol(), portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRulePortMax(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix());
- // No need to drop until UDP/ICMP are implemented
- // egressACLDefaultTcpDrop(dpid, segmentationId, attachedMac, PROTO_MATCH_PRIORITY_DROP, true);
- egressAllowProto(dpid, segmentationId, attachedMac, true,
- portSecurityRule.getSecurityRuleProtocol(), Constants.PROTO_MATCH_PRIORITY);
- continue;
+ if (write) {
+ securityGroupCacheManger.portAdded(securityGroup.getSecurityGroupUUID(), portUuid);
+ } else {
+ securityGroupCacheManger.portRemoved(securityGroup.getSecurityGroupUUID(), portUuid);
}
- LOG.debug("ACL Match combination not found for rule: {}", portSecurityRule);
- }*/
+ }
}
}
@Override
- public void programFixedSecurityAcl(Long dpid, String segmentationId, String attachedMac,
+ public void programPortSecurityRule(Long dpid, String segmentationId, String attachedMac,
+ long localPort, NeutronSecurityRule portSecurityRule,
+ Neutron_IPs vmIp, boolean write) {
+ if (null == portSecurityRule.getSecurityRuleProtocol()) {
+ /* TODO Rework on the priority values */
+ egressAclIPv4(dpid, segmentationId, attachedMac,
+ write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
+ } else {
+ String ipaddress = null;
+ if (null != vmIp) {
+ ipaddress = vmIp.getIpAddress();
+ }
+ switch (portSecurityRule.getSecurityRuleProtocol()) {
+ case MatchUtils.TCP:
+ LOG.debug("programPortSecurityRule: Rule matching TCP", portSecurityRule);
+ egressAclTcp(dpid, segmentationId, attachedMac,
+ portSecurityRule,ipaddress, write,
+ Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
+ break;
+ case MatchUtils.UDP:
+ LOG.debug("programPortSecurityRule: Rule matching UDP", portSecurityRule);
+ egressAclUdp(dpid, segmentationId, attachedMac,
+ portSecurityRule, ipaddress, write,
+ Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
+ break;
+ case MatchUtils.ICMP:
+ LOG.debug("programPortSecurityRule: Rule matching ICMP", portSecurityRule);
+ egressAclIcmp(dpid, segmentationId, attachedMac,
+ portSecurityRule, ipaddress,write,
+ Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
+ break;
+ default:
+ LOG.info("programPortSecurityAcl: Protocol is not TCP/UDP/ICMP but other " +
+ "protocol = ", portSecurityRule.getSecurityRuleProtocol());
+ egressOtherProtocolAclHandler(dpid, segmentationId, attachedMac,
+ portSecurityRule, ipaddress, write,
+ Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
+ break;
+ }
+ }
+
+ }
+
+ private void egressOtherProtocolAclHandler(Long dpidLong, String segmentationId, String srcMac,
+ NeutronSecurityRule portSecurityRule, String dstAddress,
+ boolean write, Integer protoPortMatchPriority) {
+
+ MatchBuilder matchBuilder = new MatchBuilder();
+ String flowId = "Egress_Other_" + segmentationId + "_" + srcMac + "_";
+ matchBuilder = MatchUtils.createEtherMatchWithType(matchBuilder,srcMac,null);
+
+ short proto = 0;
+ try {
+ Integer protocol = new Integer(portSecurityRule.getSecurityRuleProtocol());
+ proto = protocol.shortValue();
+ flowId = flowId + proto;
+ } catch (NumberFormatException e) {
+ LOG.error("Protocol vlaue conversion failure", e);
+ }
+ matchBuilder = MatchUtils.createIpProtocolMatch(matchBuilder, proto);
+
+ if (null != dstAddress) {
+ flowId = flowId + dstAddress;
+ matchBuilder = MatchUtils.addRemoteIpPrefix(matchBuilder,null,
+ MatchUtils.iPv4PrefixFromIPv4Address(dstAddress));
+
+ } else if (null != portSecurityRule.getSecurityRuleRemoteIpPrefix()) {
+ flowId = flowId + portSecurityRule.getSecurityRuleRemoteIpPrefix();
+ matchBuilder = MatchUtils.addRemoteIpPrefix(matchBuilder, null,new Ipv4Prefix(portSecurityRule
+ .getSecurityRuleRemoteIpPrefix()));
+ }
+ flowId = flowId + "_Permit";
+ String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpidLong;
+ NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
+ syncFlow(flowId, nodeBuilder, matchBuilder, protoPortMatchPriority, write, false);
+ }
+
+ @Override
+ public void programFixedSecurityGroup(Long dpid, String segmentationId, String attachedMac,
long localPort, List<Neutron_IPs> srcAddressList,
boolean isLastPortinBridge, boolean isComputePort ,boolean write) {
// If it is the only port in the bridge add the rule to allow any DHCP client traffic
portSecurityRule.getSecurityRulePortMin());
} else {
/* All TCP Match */
- if(portSecurityRule.getSecurityRulePortMin().equals(PORT_RANGE_MIN)
+ if (portSecurityRule.getSecurityRulePortMin().equals(PORT_RANGE_MIN)
&& portSecurityRule.getSecurityRulePortMax().equals(PORT_RANGE_MAX)) {
- flowId = flowId + portSecurityRule.getSecurityRulePortMin() + "_" +
- portSecurityRule.getSecurityRulePortMax()+ "_";
+ flowId = flowId + portSecurityRule.getSecurityRulePortMin() + "_"
+ + portSecurityRule.getSecurityRulePortMax() + "_";
matchBuilder = MatchUtils.addLayer4Match(matchBuilder, MatchUtils.TCP_SHORT, 0, 0);
}
/*TODO TCP PortRange Match*/
if (null != dstAddress) {
flowId = flowId + dstAddress;
matchBuilder = MatchUtils.addRemoteIpPrefix(matchBuilder,null,
- MatchUtils.iPv4PrefixFromIPv4Address(dstAddress));
+ MatchUtils.iPv4PrefixFromIPv4Address(dstAddress));
} else if (null != portSecurityRule.getSecurityRuleRemoteIpPrefix()) {
flowId = flowId + portSecurityRule.getSecurityRuleRemoteIpPrefix();
matchBuilder = MatchUtils.addRemoteIpPrefix(matchBuilder,null,
- new Ipv4Prefix(portSecurityRule
- .getSecurityRuleRemoteIpPrefix()));
+ new Ipv4Prefix(portSecurityRule.getSecurityRuleRemoteIpPrefix()));
}
flowId = flowId + "_Permit";
String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpidLong;
private void egressAclIcmp(Long dpidLong, String segmentationId, String srcMac,
NeutronSecurityRule portSecurityRule, String dstAddress,
boolean write, Integer protoPortMatchPriority) {
+
MatchBuilder matchBuilder = new MatchBuilder();
- String flowId = "Egress_ICMP_" + segmentationId + "_" + srcMac + "_"
- + portSecurityRule.getSecurityRulePortMin().shortValue() + "_"
- + portSecurityRule.getSecurityRulePortMax().shortValue() + "_";
+ String flowId = "Egress_ICMP_" + segmentationId + "_" + srcMac + "_";
matchBuilder = MatchUtils.createEtherMatchWithType(matchBuilder,srcMac,null);
- matchBuilder = MatchUtils.createICMPv4Match(matchBuilder,
- portSecurityRule.getSecurityRulePortMin().shortValue(),
- portSecurityRule.getSecurityRulePortMax().shortValue());
+ /*Custom ICMP Match */
+ if (portSecurityRule.getSecurityRulePortMin() != null &&
+ portSecurityRule.getSecurityRulePortMax() != null) {
+ flowId = flowId + portSecurityRule.getSecurityRulePortMin().shortValue() + "_"
+ + portSecurityRule.getSecurityRulePortMax().shortValue() + "_";
+ matchBuilder = MatchUtils.createICMPv4Match(matchBuilder,
+ portSecurityRule.getSecurityRulePortMin().shortValue(),
+ portSecurityRule.getSecurityRulePortMax().shortValue());
+ } else {
+ /* All ICMP Match */ // We are getting from neutron NULL for both min and max
+ flowId = flowId + "all" + "_" ;
+ matchBuilder = MatchUtils.createICMPv4Match(matchBuilder, MatchUtils.ALL_ICMP, MatchUtils.ALL_ICMP);
+ }
if (null != dstAddress) {
flowId = flowId + dstAddress;
matchBuilder = MatchUtils.addRemoteIpPrefix(matchBuilder,null,
portSecurityRule.getSecurityRulePortMin());
} else {
/* All UDP Match */
- if(portSecurityRule.getSecurityRulePortMin().equals(PORT_RANGE_MIN)
+ if (portSecurityRule.getSecurityRulePortMin().equals(PORT_RANGE_MIN)
&& portSecurityRule.getSecurityRulePortMax().equals(PORT_RANGE_MAX)) {
- flowId = flowId + portSecurityRule.getSecurityRulePortMin() + "_" +
- portSecurityRule.getSecurityRulePortMax()+ "_";
+ flowId = flowId + portSecurityRule.getSecurityRulePortMin() + "_"
+ + portSecurityRule.getSecurityRulePortMax() + "_";
matchBuilder = MatchUtils.addLayer4Match(matchBuilder, MatchUtils.UDP_SHORT, 0, 0);
}
/*TODO UDP PortRange Match*/
super.setDependencies(bundleContext.getServiceReference(EgressAclProvider.class.getName()), this);
securityServicesManager =
(SecurityServicesManager) ServiceHelper.getGlobalInstance(SecurityServicesManager.class, this);
+ securityGroupCacheManger =
+ (SecurityGroupCacheManger) ServiceHelper.getGlobalInstance(SecurityGroupCacheManger.class, this);
}
@Override
package org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.services;
-import java.math.BigInteger;
-import java.util.List;
-import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
-import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
-import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import com.google.common.collect.Lists;
+
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
import org.opendaylight.ovsdb.openstack.netvirt.api.IngressAclProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityGroupCacheManger;
import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager;
import org.opendaylight.ovsdb.openstack.netvirt.providers.ConfigInterface;
import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.AbstractServiceInstance;
import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
import org.opendaylight.ovsdb.utils.mdsal.openflow.InstructionUtils;
import org.opendaylight.ovsdb.utils.mdsal.openflow.MatchUtils;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.Lists;
+import java.math.BigInteger;
+import java.util.List;
+
+
public class IngressAclService extends AbstractServiceInstance implements IngressAclProvider, ConfigInterface {
private static final Logger LOG = LoggerFactory.getLogger(IngressAclService.class);
private volatile SecurityServicesManager securityServicesManager;
+ private volatile SecurityGroupCacheManger securityGroupCacheManger;
private static final int PORT_RANGE_MIN = 1;
private static final int PORT_RANGE_MAX = 65535;
}
@Override
- public void programPortSecurityAcl(Long dpid, String segmentationId, String attachedMac,
+ public void programPortSecurityGroup(Long dpid, String segmentationId, String attachedMac,
long localPort, NeutronSecurityGroup securityGroup,
- List<Neutron_IPs> srcAddressList, boolean write) {
+ String portUuid, boolean write) {
- LOG.trace("programLocalBridgeRulesWithSec neutronSecurityGroup: {} ", securityGroup);
+ LOG.trace("programPortSecurityGroup neutronSecurityGroup: {} ", securityGroup);
if (securityGroup == null || securityGroup.getSecurityRules() == null) {
return;
}
List<NeutronSecurityRule> portSecurityList = securityGroup.getSecurityRules();
/* Iterate over the Port Security Rules in the Port Security Group bound to the port*/
for (NeutronSecurityRule portSecurityRule : portSecurityList) {
+
/**
* Neutron Port Security Acl "ingress" and "IPv4"
* Check that the base conditions for flow based Port Security are true:
*
*/
+ if (portSecurityRule == null ||
+ portSecurityRule.getSecurityRuleEthertype() == null ||
+ portSecurityRule.getSecurityRuleDirection() == null) {
+ continue;
+ }
+
if ("IPv4".equals(portSecurityRule.getSecurityRuleEthertype())
&& "ingress".equals(portSecurityRule.getSecurityRuleDirection())) {
- LOG.debug("Acl Rule matching IPv4 and ingress is: {} ", portSecurityRule);
- if (null == portSecurityRule.getSecurityRuleProtocol()) {
- ingressAclIPv4(dpid, segmentationId, attachedMac,
- write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- } else if (null != portSecurityRule.getSecurityRemoteGroupID()) {
+ LOG.debug("programPortSecurityGroup: Rule matching IPv4 and ingress is: {} ", portSecurityRule);
+ if (null != portSecurityRule.getSecurityRemoteGroupID()) {
//Remote Security group is selected
List<Neutron_IPs> remoteSrcAddressList = securityServicesManager
- .getVmListForSecurityGroup(srcAddressList,portSecurityRule.getSecurityRemoteGroupID());
+ .getVmListForSecurityGroup(portUuid,portSecurityRule.getSecurityRemoteGroupID());
if (null != remoteSrcAddressList) {
for (Neutron_IPs vmIp :remoteSrcAddressList ) {
- switch (portSecurityRule.getSecurityRuleProtocol()) {
- case MatchUtils.TCP:
- ingressAclTcp(dpid, segmentationId, attachedMac, portSecurityRule,
- vmIp.getIpAddress(),write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- break;
- case MatchUtils.UDP:
- ingressAclUdp(dpid, segmentationId, attachedMac, portSecurityRule,
- vmIp.getIpAddress(), write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- break;
- case MatchUtils.ICMP:
- ingressAclIcmp(dpid, segmentationId, attachedMac, portSecurityRule,
- vmIp.getIpAddress(), write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- break;
- default:
- LOG.error("programPortSecurityAcl: Protocol not supported", portSecurityRule);
- break;
- }
+ programPortSecurityRule(dpid, segmentationId, attachedMac, localPort,
+ portSecurityRule, vmIp, write);
+ }
+ if (write) {
+ securityGroupCacheManger.addToCache(portSecurityRule.getSecurityRemoteGroupID(), portUuid);
+ } else {
+ securityGroupCacheManger.removeFromCache(portSecurityRule.getSecurityRemoteGroupID(),
+ portUuid);
}
}
} else {
- //CIDR is selected
- switch (portSecurityRule.getSecurityRuleProtocol()) {
- case MatchUtils.TCP:
- ingressAclTcp(dpid, segmentationId, attachedMac,
- portSecurityRule, null, write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- break;
- case MatchUtils.UDP:
- ingressAclUdp(dpid, segmentationId, attachedMac,
- portSecurityRule, null, write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- break;
- case MatchUtils.ICMP:
- ingressAclIcmp(dpid, segmentationId, attachedMac, portSecurityRule, null,
- write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- break;
- default:
- LOG.error("programPortSecurityAcl: Protocol not supported", portSecurityRule);
- }
- }
-
- /**
- * TCP Proto (True), TCP Port Minimum (True), TCP Port Max (True), IP Prefix (True)
- * TODO Some part of the code will be used when conntrack is supported
-
- if (String.valueOf(portSecurityRule.getSecurityRuleProtocol()).equalsIgnoreCase("tcp") &&
- !String.valueOf(portSecurityRule.getSecurityRulePortMin()).equalsIgnoreCase("null") &&
- !String.valueOf(portSecurityRule.getSecurityRulePortMax()).equalsIgnoreCase("null") &&
- (!String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix()).equalsIgnoreCase("null") &&
- !String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix())
- .equalsIgnoreCase("0.0.0.0/0"))) {
- LOG.debug("Rule #1 ingress PortSec Rule Matches -> TCP Protocol: {}, TCP Port Min: {}, TCP Port Max: {}, IP Prefix: {}",
- portSecurityRule.getSecurityRuleProtocol(), portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRulePortMax(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix());
- ingressACLDefaultTcpDrop(dpid, segmentationId, attachedMac,
- Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY_DROP,
- true);
- ingressACLTcpPortWithPrefix(dpid, segmentationId,
- attachedMac, true, portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix(), Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- continue;
- }
- /**
- * TCP Proto (True), TCP Port Minimum (True), TCP Port Max (False), IP Prefix (True)
- */
- /*if (String.valueOf(portSecurityRule.getSecurityRuleProtocol()).equalsIgnoreCase("tcp") &&
- !String.valueOf(portSecurityRule.getSecurityRulePortMin()).equalsIgnoreCase("null") &&
- String.valueOf(portSecurityRule.getSecurityRulePortMax()).equalsIgnoreCase("null") &&
- (!String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix()).equalsIgnoreCase("null") &&
- !String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix())
- .equalsIgnoreCase("0.0.0.0/0"))) {
- LOG.debug("Rule #2 ingress PortSec Rule Matches -> TCP Protocol: {}, TCP Port Min: {}, TCP Port Max: {}, IP Prefix: {}",
- portSecurityRule.getSecurityRuleProtocol(), portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRulePortMax(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix());
- ingressACLDefaultTcpDrop(dpid, segmentationId, attachedMac,
- Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY_DROP,
- true);
- ingressACLTcpPortWithPrefix(dpid, segmentationId,
- attachedMac, true, portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix(), Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
- continue;
- }
- *//**
- * TCP Proto (True), TCP Port Minimum (False), TCP Port Max (False), IP Prefix (True)
- *//*
- if (String.valueOf(portSecurityRule.getSecurityRuleProtocol()).equalsIgnoreCase("tcp") &&
- String.valueOf(portSecurityRule.getSecurityRulePortMin()).equalsIgnoreCase("null") &&
- String.valueOf(portSecurityRule.getSecurityRulePortMax()).equalsIgnoreCase("null") &&
- !String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix()).equalsIgnoreCase("null")) {
- LOG.debug("Rule #3 ingress PortSec Rule Matches -> TCP Protocol: {}, TCP Port Min: {}, TCP Port Max: {}, IP Prefix: {}",
- portSecurityRule.getSecurityRuleProtocol(), portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRulePortMax(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix());
- ingressACLDefaultTcpDrop(dpid, segmentationId, attachedMac, Constants.PROTO_PREFIX_MATCH_PRIORITY_DROP,
- true);
- ingressACLPermitAllProto(dpid, segmentationId, attachedMac, true,
- portSecurityRule.getSecurityRuleRemoteIpPrefix(), Constants.PROTO_PREFIX_MATCH_PRIORITY);
- continue;
- }
- *//**
- * TCP Proto (False), TCP Port Minimum (False), TCP Port Max (False), IP Prefix (True)
- *//*
- if (String.valueOf(portSecurityRule.getSecurityRuleProtocol()).equalsIgnoreCase("null") &&
- String.valueOf(portSecurityRule.getSecurityRulePortMin()).equalsIgnoreCase("null") &&
- String.valueOf(portSecurityRule.getSecurityRulePortMin()).equalsIgnoreCase("null") &&
- (!String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix()).equalsIgnoreCase("null") &&
- !String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix())
- .equalsIgnoreCase("0.0.0.0/0"))) {
- LOG.debug("Rule #4 ingress PortSec Rule Matches -> TCP Protocol: {}, TCP Port Min: {}, TCP Port Max: {}, IP Prefix: {}",
- portSecurityRule.getSecurityRuleProtocol(), portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRulePortMax(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix());
- ingressACLDefaultTcpDrop(dpid, segmentationId, attachedMac, Constants.PREFIX_MATCH_PRIORITY_DROP, true);
- ingressACLPermitAllProto(dpid, segmentationId, attachedMac, true,
- portSecurityRule.getSecurityRuleRemoteIpPrefix(), Constants.PREFIX_MATCH_PRIORITY);
- continue;
+ programPortSecurityRule(dpid, segmentationId, attachedMac, localPort,
+ portSecurityRule, null, write);
}
- *//**
- * TCP Proto (True), TCP Port Minimum (True), TCP Port Max (True), IP Prefix (False)
- *//*
- if (String.valueOf(portSecurityRule.getSecurityRuleProtocol()).equalsIgnoreCase("tcp") &&
- !String.valueOf(portSecurityRule.getSecurityRulePortMin()).equalsIgnoreCase("null") &&
- !String.valueOf(portSecurityRule.getSecurityRulePortMax()).equalsIgnoreCase("null") &&
- String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix()).equalsIgnoreCase("null")) {
- LOG.debug("Rule #5 ingress PortSec Rule Matches -> TCP Protocol: {}, TCP Port Min: {}, TCP Port Max: {}, IP Prefix: {}",
- portSecurityRule.getSecurityRuleProtocol(), portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRulePortMax(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix());
- ingressACLDefaultTcpDrop(dpid, segmentationId, attachedMac, Constants.PROTO_PORT_MATCH_PRIORITY_DROP,
- true);
- ingressACLTcpSyn(dpid, segmentationId,
- attachedMac, true, portSecurityRule.getSecurityRulePortMin(),
- Constants.PREFIX_PORT_MATCH_PRIORITY_DROP);
- continue;
- }
- *//**
- * TCP Proto (True), TCP Port Minimum (True), TCP Port Max (False), IP Prefix (False)
- *//*
- if (String.valueOf(portSecurityRule.getSecurityRuleProtocol()).equalsIgnoreCase("tcp") &&
- !String.valueOf(portSecurityRule.getSecurityRulePortMin()).equalsIgnoreCase("null") &&
- String.valueOf(portSecurityRule.getSecurityRulePortMax()).equalsIgnoreCase("null") &&
- String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix()).equalsIgnoreCase("null")) {
- LOG.debug("Rule #6 ingress PortSec Rule Matches -> TCP Protocol: {}, TCP Port Min: {}, TCP Port Max: {}, IP Prefix: {}",
- portSecurityRule.getSecurityRuleProtocol(), portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRulePortMax(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix());
- ingressACLDefaultTcpDrop(dpid, segmentationId, attachedMac,
- Constants.PROTO_PORT_MATCH_PRIORITY_DROP, true);
- ingressACLTcpSyn(dpid, segmentationId, attachedMac, true,
- portSecurityRule.getSecurityRulePortMin(), Constants.PROTO_PORT_MATCH_PRIORITY);
- continue;
+ if (write) {
+ securityGroupCacheManger.portAdded(securityGroup.getSecurityGroupUUID(), portUuid);
+ } else {
+ securityGroupCacheManger.portRemoved(securityGroup.getSecurityGroupUUID(), portUuid);
}
- *//**
- * TCP Proto (True), TCP Port Minimum (False), TCP Port Max (False), IP Prefix (False or 0.0.0.0/0)
- *//*
- if (String.valueOf(portSecurityRule.getSecurityRuleProtocol()).equalsIgnoreCase("tcp") &&
- String.valueOf(portSecurityRule.getSecurityRulePortMin()).equalsIgnoreCase("null") &&
- String.valueOf(portSecurityRule.getSecurityRulePortMax()).equalsIgnoreCase("null") &&
- ((String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix()).equalsIgnoreCase("null")) ||
- String.valueOf(portSecurityRule.getSecurityRuleRemoteIpPrefix())
- .equalsIgnoreCase("0.0.0.0/0"))) {
- LOG.debug("Rule #7 ingress PortSec Rule Matches -> TCP Protocol: {}, TCP Port Min: {}, TCP Port Max: {}, IP Prefix: {}",
- portSecurityRule.getSecurityRuleProtocol(), portSecurityRule.getSecurityRulePortMin(),
- portSecurityRule.getSecurityRulePortMax(),
- portSecurityRule.getSecurityRuleRemoteIpPrefix());
- // No need to drop until UDP/ICMP are implemented
- // ingressACLDefaultTcpDrop(dpid, segmentationId, attachedMac, PROTO_MATCH_PRIORITY_DROP, true);
- handleIngressAllowProto(dpid, segmentationId, attachedMac, true,
- portSecurityRule.getSecurityRuleProtocol(), Constants.PROTO_MATCH_PRIORITY);
- continue;
- }*/
- LOG.debug("Ingress Acl Match combination not found for rule: {}", portSecurityRule);
}
}
}
@Override
- public void programFixedSecurityAcl(Long dpid, String segmentationId, String dhcpMacAddress,
+ public void programPortSecurityRule(Long dpid, String segmentationId, String attachedMac,
+ long localPort, NeutronSecurityRule portSecurityRule,
+ Neutron_IPs vmIp, boolean write) {
+ if (null == portSecurityRule.getSecurityRuleProtocol()) {
+ ingressAclIPv4(dpid, segmentationId, attachedMac,
+ write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
+ } else {
+ String ipaddress = null;
+ if (null != vmIp) {
+ ipaddress = vmIp.getIpAddress();
+ }
+ switch (portSecurityRule.getSecurityRuleProtocol()) {
+ case MatchUtils.TCP:
+ LOG.debug("programPortSecurityRule: Rule matching TCP", portSecurityRule);
+ ingressAclTcp(dpid, segmentationId, attachedMac, portSecurityRule, ipaddress,
+ write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
+ break;
+ case MatchUtils.UDP:
+ LOG.debug("programPortSecurityRule: Rule matching UDP", portSecurityRule);
+ ingressAclUdp(dpid, segmentationId, attachedMac, portSecurityRule, ipaddress,
+ write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
+ break;
+ case MatchUtils.ICMP:
+ LOG.debug("programPortSecurityRule: Rule matching ICMP", portSecurityRule);
+ ingressAclIcmp(dpid, segmentationId, attachedMac, portSecurityRule, ipaddress,
+ write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
+ break;
+ default:
+ LOG.info("programPortSecurityAcl: Protocol is not TCP/UDP/ICMP but other " +
+ "protocol = ", portSecurityRule.getSecurityRuleProtocol());
+ ingressOtherProtocolAclHandler(dpid, segmentationId, attachedMac, portSecurityRule,
+ null, write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
+ break;
+ }
+ }
+ }
+
+ private void ingressOtherProtocolAclHandler(Long dpidLong, String segmentationId, String dstMac,
+ NeutronSecurityRule portSecurityRule, String srcAddress,
+ boolean write, Integer protoPortMatchPriority) {
+
+ MatchBuilder matchBuilder = new MatchBuilder();
+ String flowId = "Ingress_Other_" + segmentationId + "_" + dstMac + "_";
+ matchBuilder = MatchUtils.createEtherMatchWithType(matchBuilder,null,dstMac);
+ short proto = 0;
+ try {
+ Integer protocol = new Integer(portSecurityRule.getSecurityRuleProtocol());
+ proto = protocol.shortValue();
+ flowId = flowId + proto;
+ } catch (NumberFormatException e) {
+ LOG.error("Protocol vlaue conversion failure", e);
+ }
+ matchBuilder = MatchUtils.createIpProtocolMatch(matchBuilder, proto);
+ if (null != srcAddress) {
+ flowId = flowId + srcAddress;
+ matchBuilder = MatchUtils.addRemoteIpPrefix(matchBuilder,
+ MatchUtils.iPv4PrefixFromIPv4Address(srcAddress), null);
+ } else if (null != portSecurityRule.getSecurityRuleRemoteIpPrefix()) {
+ flowId = flowId + portSecurityRule.getSecurityRuleRemoteIpPrefix();
+ matchBuilder = MatchUtils.addRemoteIpPrefix(matchBuilder,
+ new Ipv4Prefix(portSecurityRule.getSecurityRuleRemoteIpPrefix()),null);
+ }
+ String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpidLong;
+ NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
+ flowId = flowId + "_Permit";
+ syncFlow(flowId, nodeBuilder, matchBuilder, protoPortMatchPriority, write, false);
+ }
+
+ @Override
+ public void programFixedSecurityGroup(Long dpid, String segmentationId, String dhcpMacAddress,
long localPort, boolean isLastPortinSubnet,
boolean isComputePort, boolean write) {
//If this port is the only port in the compute node add the DHCP server rule.
* @param protoPortMatchPriority the protocol match priority.
*/
private void ingressAclIPv4(Long dpidLong, String segmentationId, String dstMac,
- boolean write, Integer protoPortMatchPriority ) {
+ boolean write, Integer protoPortMatchPriority ) {
String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpidLong;
MatchBuilder matchBuilder = new MatchBuilder();
NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
* @param protoPortMatchPriority the protocol match priroty
*/
private void ingressAclTcp(Long dpidLong, String segmentationId, String dstMac,
- NeutronSecurityRule portSecurityRule, String srcAddress, boolean write,
- Integer protoPortMatchPriority ) {
+ NeutronSecurityRule portSecurityRule, String srcAddress, boolean write,
+ Integer protoPortMatchPriority ) {
MatchBuilder matchBuilder = new MatchBuilder();
FlowBuilder flowBuilder = new FlowBuilder();
if (portSecurityRule.getSecurityRulePortMin().equals(portSecurityRule.getSecurityRulePortMax())) {
flowId = flowId + portSecurityRule.getSecurityRulePortMin() + "_";
matchBuilder = MatchUtils.addLayer4Match(matchBuilder, MatchUtils.TCP_SHORT, 0,
- portSecurityRule.getSecurityRulePortMin());
+ portSecurityRule.getSecurityRulePortMin());
} else {
/* All TCP Match */
- if(portSecurityRule.getSecurityRulePortMin().equals(PORT_RANGE_MIN)
+ if (portSecurityRule.getSecurityRulePortMin().equals(PORT_RANGE_MIN)
&& portSecurityRule.getSecurityRulePortMax().equals(PORT_RANGE_MAX)) {
- flowId = flowId + portSecurityRule.getSecurityRulePortMin() + "_" +
- portSecurityRule.getSecurityRulePortMax()+ "_";
+ flowId = flowId + portSecurityRule.getSecurityRulePortMin() + "_"
+ + portSecurityRule.getSecurityRulePortMax() + "_";
matchBuilder = MatchUtils.addLayer4Match(matchBuilder, MatchUtils.TCP_SHORT, 0, 0);
}
/*TODO TCP PortRange Match*/
* @param protoPortMatchPriority the protocol match priroty
*/
private void ingressAclUdp(Long dpidLong, String segmentationId, String dstMac,
- NeutronSecurityRule portSecurityRule, String srcAddress,
- boolean write, Integer protoPortMatchPriority ) {
+ NeutronSecurityRule portSecurityRule, String srcAddress,
+ boolean write, Integer protoPortMatchPriority ) {
MatchBuilder matchBuilder = new MatchBuilder();
String flowId = "Ingress_UDP_" + segmentationId + "_" + dstMac + "_";
matchBuilder = MatchUtils.createEtherMatchWithType(matchBuilder,null,dstMac);
if (portSecurityRule.getSecurityRulePortMin().equals(portSecurityRule.getSecurityRulePortMax())) {
flowId = flowId + portSecurityRule.getSecurityRulePortMin() + "_";
matchBuilder = MatchUtils.addLayer4Match(matchBuilder, MatchUtils.UDP_SHORT, 0,
- portSecurityRule.getSecurityRulePortMin());
+ portSecurityRule.getSecurityRulePortMin());
} else {
/* All UDP Match */
- if(portSecurityRule.getSecurityRulePortMin().equals(PORT_RANGE_MIN)
+ if (portSecurityRule.getSecurityRulePortMin().equals(PORT_RANGE_MIN)
&& portSecurityRule.getSecurityRulePortMax().equals(PORT_RANGE_MAX)) {
- flowId = flowId + portSecurityRule.getSecurityRulePortMin() + "_" +
- portSecurityRule.getSecurityRulePortMax()+ "_";
+ flowId = flowId + portSecurityRule.getSecurityRulePortMin() + "_"
+ + portSecurityRule.getSecurityRulePortMax() + "_";
matchBuilder = MatchUtils.addLayer4Match(matchBuilder, MatchUtils.UDP_SHORT, 0, 0);
}
/*TODO TCP PortRange Match*/
} else if (null != portSecurityRule.getSecurityRuleRemoteIpPrefix()) {
flowId = flowId + portSecurityRule.getSecurityRuleRemoteIpPrefix();
matchBuilder = MatchUtils.addRemoteIpPrefix(matchBuilder,
- new Ipv4Prefix(portSecurityRule.getSecurityRuleRemoteIpPrefix()),null);
+ new Ipv4Prefix(portSecurityRule
+ .getSecurityRuleRemoteIpPrefix()),null);
}
String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpidLong;
NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
boolean write, Integer protoPortMatchPriority) {
MatchBuilder matchBuilder = new MatchBuilder();
- FlowBuilder flowBuilder = new FlowBuilder();
- String flowId = "Ingress_ICMP_" + segmentationId + "_" + dstMac + "_"
- + portSecurityRule.getSecurityRulePortMin().shortValue() + "_"
- + portSecurityRule.getSecurityRulePortMax().shortValue() + "_";;
+ String flowId = "Ingress_ICMP_" + segmentationId + "_" + dstMac + "_";
matchBuilder = MatchUtils.createEtherMatchWithType(matchBuilder,null,dstMac);
- matchBuilder = MatchUtils.createICMPv4Match(matchBuilder,
- portSecurityRule.getSecurityRulePortMin().shortValue(),
- portSecurityRule.getSecurityRulePortMax().shortValue());
+
+ /* Custom ICMP Match */
+ if (portSecurityRule.getSecurityRulePortMin() != null &&
+ portSecurityRule.getSecurityRulePortMax() != null) {
+ flowId = flowId + portSecurityRule.getSecurityRulePortMin().shortValue() + "_"
+ + portSecurityRule.getSecurityRulePortMax().shortValue() + "_";
+ matchBuilder = MatchUtils.createICMPv4Match(matchBuilder,
+ portSecurityRule.getSecurityRulePortMin().shortValue(),
+ portSecurityRule.getSecurityRulePortMax().shortValue());
+ } else {
+ /* All ICMP Match */
+ flowId = flowId + "all" + "_";
+ matchBuilder = MatchUtils.createICMPv4Match(matchBuilder,MatchUtils.ALL_ICMP, MatchUtils.ALL_ICMP);
+ }
if (null != srcAddress) {
flowId = flowId + srcAddress;
matchBuilder = MatchUtils.addRemoteIpPrefix(matchBuilder,
- MatchUtils.iPv4PrefixFromIPv4Address(srcAddress), null);
-
+ MatchUtils.iPv4PrefixFromIPv4Address(srcAddress), null);
} else if (null != portSecurityRule.getSecurityRuleRemoteIpPrefix()) {
flowId = flowId + portSecurityRule.getSecurityRuleRemoteIpPrefix();
matchBuilder = MatchUtils.addRemoteIpPrefix(matchBuilder,
- new Ipv4Prefix(portSecurityRule.getSecurityRuleRemoteIpPrefix()),null);
+ new Ipv4Prefix(portSecurityRule
+ .getSecurityRuleRemoteIpPrefix()),null);
}
String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpidLong;
NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
syncFlow(flowId, nodeBuilder, matchBuilder, protoPortMatchPriority, write, false);
}
+
public void ingressACLTcpSyn(Long dpidLong, String segmentationId, String attachedMac, boolean write,
Integer securityRulePortMin, Integer protoPortMatchPriority) {
super.setDependencies(bundleContext.getServiceReference(IngressAclProvider.class.getName()), this);
securityServicesManager =
(SecurityServicesManager) ServiceHelper.getGlobalInstance(SecurityServicesManager.class, this);
+ securityGroupCacheManger =
+ (SecurityGroupCacheManger) ServiceHelper.getGlobalInstance(SecurityGroupCacheManger.class, this);
}
@Override
public Arp() {
payload = null;
- hdrFieldsMap = new HashMap<String, byte[]>(ARP_FIELDS_COUNT);
+ hdrFieldsMap = new HashMap<>(ARP_FIELDS_COUNT);
setHardwareLength((short) 6); // MAC address length
setProtocolLength((short) 4); // IPv4 address length
setHardwareType(ETHERNET_HW_TYPE);
*/
public static EthernetMatch createEthernetMatch(MacAddress destinationMacAddress) {
return new EthernetMatchBuilder().setEthernetType(
- new EthernetTypeBuilder().setType(new EtherType(Long.valueOf(EtherTypes.ARP.intValue()))).build())
+ new EthernetTypeBuilder().setType(new EtherType((long) EtherTypes.ARP.intValue())).build())
.setEthernetDestination(new EthernetDestinationBuilder().setAddress(destinationMacAddress).build())
.build();
}
private final int intOperation;
- private ArpOperation(int operationNumber) {
+ ArpOperation(int operationNumber) {
this.intOperation = operationNumber;
}
@Test
public void testProgramDefaultPipelineRule() {
when(southbound.getBridgeName(any(Node.class))).thenReturn(Constants.INTEGRATION_BRIDGE);
- when(southbound.getDataPathId(any(Node.class))).thenReturn(Long.valueOf(261));
+ when(southbound.getDataPathId(any(Node.class))).thenReturn(261L);
when(orchestrator.getNextServiceInPipeline(any(Service.class))).thenReturn(Service.ARP_RESPONDER);
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
-import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
+import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityGroupCacheManger;
import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager;
import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.PipelineOrchestrator;
import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
@Mock private NeutronSecurityRule portSecurityRule;
@Mock private SecurityServicesManager securityServices;
+ @Mock private SecurityGroupCacheManger securityGroupCacheManger;
private Neutron_IPs neutron_ip_src;
private Neutron_IPs neutron_ip_dest_1;
private Neutron_IPs neutron_ip_dest_2;
- private List<Neutron_IPs> neutronSrcIpList = new ArrayList<Neutron_IPs>();
- private List<Neutron_IPs> neutronDestIpList = new ArrayList<Neutron_IPs>();
+ private List<Neutron_IPs> neutronSrcIpList = new ArrayList<>();
+ private List<Neutron_IPs> neutronDestIpList = new ArrayList<>();
private static final String HOST_ADDRESS = "127.0.0.1/32";
private static final String MAC_ADDRESS = "87:1D:5E:02:40:B7";
private static final String SRC_IP = "192.168.0.1";
private static final String DEST_IP_1_WITH_MASK = "192.169.0.1/32";
private static final String DEST_IP_2_WITH_MASK = "192.169.0.2/32";
private static final String SECURITY_GROUP_UUID = "85cc3048-abc3-43cc-89b3-377341426ac5";
+ private static final String PORT_UUID = "95cc3048-abc3-43cc-89b3-377341426ac5";
private static final String SEGMENT_ID = "2";
private static final Long DP_ID_LONG = (long) 1554;
private static final Long LOCAL_PORT = (long) 124;
when(portSecurityRule.getSecurityRuleEthertype()).thenReturn("IPv4");
when(portSecurityRule.getSecurityRuleDirection()).thenReturn("egress");
- List<NeutronSecurityRule> portSecurityList = new ArrayList<NeutronSecurityRule>();
+ List<NeutronSecurityRule> portSecurityList = new ArrayList<>();
portSecurityList.add(portSecurityRule);
neutron_ip_src = new Neutron_IPs();
neutronDestIpList.add(neutron_ip_dest_2);
when(securityGroup.getSecurityRules()).thenReturn(portSecurityList);
- when(securityServices.getVmListForSecurityGroup(neutronSrcIpList, SECURITY_GROUP_UUID)).thenReturn(neutronDestIpList);
+ when(securityServices.getVmListForSecurityGroup(PORT_UUID, SECURITY_GROUP_UUID)).thenReturn(neutronDestIpList);
}
/**
verify(commitFuture, times(1)).get();
}
*/
+ /**
+ * Test method {@link EgressAclService#programPortSecurityGroup(java.lang.Long, java.lang.String,
+ * java.lang.String, long, org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup,
+ * java.lang.String, boolean)} when portSecurityRule is incomplete
+ */
+ @Test
+ public void testProgramPortSecurityGroupWithIncompleteRule() throws Exception {
+ NeutronSecurityRule portSecurityRule1 = mock(NeutronSecurityRule.class);
+ when(portSecurityRule1.getSecurityRuleEthertype()).thenReturn("IPv4");
+ when(portSecurityRule1.getSecurityRuleDirection()).thenReturn("not_egress"); // other direction
+
+ NeutronSecurityRule portSecurityRule2 = mock(NeutronSecurityRule.class);
+ when(portSecurityRule2.getSecurityRuleEthertype()).thenReturn(null);
+ when(portSecurityRule2.getSecurityRuleDirection()).thenReturn("egress");
+
+ NeutronSecurityRule portSecurityRule3 = mock(NeutronSecurityRule.class);
+ when(portSecurityRule3.getSecurityRuleEthertype()).thenReturn("IPv4");
+ when(portSecurityRule3.getSecurityRuleDirection()).thenReturn(null);
+
+ NeutronSecurityRule portSecurityRule4 = mock(NeutronSecurityRule.class);
+ when(portSecurityRule4.getSecurityRuleEthertype()).thenReturn(null);
+ when(portSecurityRule4.getSecurityRuleDirection()).thenReturn(null);
+
+ List<NeutronSecurityRule> portSecurityList = new ArrayList<>();
+ portSecurityList.add(null);
+ portSecurityList.add(portSecurityRule1);
+ portSecurityList.add(portSecurityRule2);
+ portSecurityList.add(portSecurityRule3);
+ portSecurityList.add(portSecurityRule4);
+
+ NeutronSecurityGroup localSecurityGroup = mock(NeutronSecurityGroup.class);
+ when(localSecurityGroup.getSecurityRules()).thenReturn(portSecurityList);
+
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT,
+ localSecurityGroup, PORT_UUID, true);
+ }
+
/**
* Test method {@link EgressAclService#egressACLDefaultTcpDrop(Long, String, String, int, boolean)}
*/
@Test
public void testEgressACLDefaultTcpDrop() throws Exception {
- egressAclService.egressACLDefaultTcpDrop(Long.valueOf(123), "2", MAC_ADDRESS, 1, true);
+ egressAclService.egressACLDefaultTcpDrop(123L, "2", MAC_ADDRESS, 1, true);
verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), anyBoolean());
verify(writeTransaction, times(1)).submit();
verify(commitFuture, times(1)).get();
- egressAclService.egressACLDefaultTcpDrop(Long.valueOf(123), "2", MAC_ADDRESS, 1, false);
+ egressAclService.egressACLDefaultTcpDrop(123L, "2", MAC_ADDRESS, 1, false);
verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(2)).submit();
verify(commitFuture, times(2)).get(); // 1 + 1 above
when(portSecurityRule.getSecurityRulePortMin()).thenReturn(null);
when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn(null);
- egressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,true);
+ egressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,true);
verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
verify(writeTransaction, times(1)).submit();
when(portSecurityRule.getSecurityRulePortMin()).thenReturn(null);
when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn(null);
- egressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,false);
+ egressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,false);
verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(1)).submit();
verify(commitFuture, times(1)).get();
when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
Icmpv4Match icmpv4Match = match.getIcmpv4Match();
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
Icmpv4Match icmpv4Match = match.getIcmpv4Match();
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
Icmpv4Match icmpv4Match = match.getIcmpv4Match();
Assert.assertTrue(true);
} else {
Assert.assertTrue(false);
- };
+ }
}
/**
PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- egressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
Icmpv4Match icmpv4Match = match.getIcmpv4Match();
public void testProgramPortSecurityACLRuleInvalidEther() throws Exception {
when(portSecurityRule.getSecurityRuleEthertype()).thenReturn("IPV6");
- egressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,false);
+ egressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,false);
verify(writeTransaction, times(0)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(0)).submit();
public void testProgramPortSecurityACLRuleInvalidDirection() throws Exception {
when(portSecurityRule.getSecurityRuleDirection()).thenReturn("ingress");
- egressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,false);
+ egressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,false);
verify(writeTransaction, times(0)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(0)).submit();
*/
@Test
public void testProgramFixedSecurityACLAdd1() throws Exception {
- egressAclServiceSpy.programFixedSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, false, true);
+ egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, false, true);
verify(writeTransaction, times(0)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
verify(writeTransaction, times(0)).submit();
@Test
public void testProgramFixedSecurityACLRemove1() throws Exception {
- egressAclServiceSpy.programFixedSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, false, false);
+ egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, false, false);
verify(writeTransaction, times(0)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(0)).submit();
@Test
public void testProgramFixedSecurityACLAdd2() throws Exception {
- egressAclServiceSpy.programFixedSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, true, true);
+ egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, true, true);
verify(writeTransaction, times(6)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
verify(writeTransaction, times(3)).submit();
@Test
public void testProgramFixedSecurityACLRemove2() throws Exception {
- egressAclServiceSpy.programFixedSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, true, false);
+ egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, true, false);
verify(writeTransaction, times(3)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(3)).submit();
@Test
public void testProgramFixedSecurityACLAdd3() throws Exception {
- egressAclServiceSpy.programFixedSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, true, false, true);
+ egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, true, false, true);
verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
verify(writeTransaction, times(1)).submit();
@Test
public void testProgramFixedSecurityACLRemove3() throws Exception {
- egressAclServiceSpy.programFixedSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, true, false, false);
+ egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, true, false, false);
verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(1)).submit();
@Test
public void testProgramFixedSecurityACLAdd4() throws Exception {
- egressAclServiceSpy.programFixedSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, true, true, true);
+ egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, true, true, true);
verify(writeTransaction, times(8)).put(any(LogicalDatastoreType.class),
any(InstanceIdentifier.class), any(Node.class), eq(true));
@Test
public void testProgramFixedSecurityACLRemove4() throws Exception {
- egressAclServiceSpy.programFixedSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, true, true, false);
+ egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, true, true, false);
verify(writeTransaction, times(4)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(4)).submit();
*/
@Test
public void testEgressACLTcpPortWithPrefix() throws Exception {
- egressAclService.egressACLTcpPortWithPrefix(Long.valueOf(123), "2", MAC_ADDRESS, true, 1, HOST_ADDRESS, 1);
+ egressAclService.egressACLTcpPortWithPrefix(123L, "2", MAC_ADDRESS, true, 1, HOST_ADDRESS, 1);
verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), anyBoolean());
verify(writeTransaction, times(1)).submit();
verify(commitFuture, times(1)).get();
- egressAclService.egressACLTcpPortWithPrefix(Long.valueOf(123), "2", MAC_ADDRESS, false, 1, HOST_ADDRESS, 1);
+ egressAclService.egressACLTcpPortWithPrefix(123L, "2", MAC_ADDRESS, false, 1, HOST_ADDRESS, 1);
verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(2)).submit();
verify(commitFuture, times(2)).get(); // 1 + 1 above
*/
@Test
public void testEgressAllowProto() throws Exception {
- egressAclService.egressAllowProto(Long.valueOf(123), "2", MAC_ADDRESS, true, HOST_ADDRESS, 1);
+ egressAclService.egressAllowProto(123L, "2", MAC_ADDRESS, true, HOST_ADDRESS, 1);
verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), anyBoolean());
verify(writeTransaction, times(1)).submit();
verify(commitFuture, times(1)).get();
- egressAclService.egressAllowProto(Long.valueOf(123), "2", MAC_ADDRESS, false, HOST_ADDRESS, 1);
+ egressAclService.egressAllowProto(123L, "2", MAC_ADDRESS, false, HOST_ADDRESS, 1);
verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(2)).submit();
verify(commitFuture, times(2)).get(); // 1 + 1 above
*/
@Test
public void testEgressACLPermitAllProto() throws Exception {
- egressAclService.egressACLPermitAllProto(Long.valueOf(123), "2", MAC_ADDRESS, true, HOST_ADDRESS, 1);
+ egressAclService.egressACLPermitAllProto(123L, "2", MAC_ADDRESS, true, HOST_ADDRESS, 1);
verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), anyBoolean());
verify(writeTransaction, times(1)).submit();
verify(commitFuture, times(1)).get();
- egressAclService.egressACLPermitAllProto(Long.valueOf(123), "2", MAC_ADDRESS, false, HOST_ADDRESS, 1);
+ egressAclService.egressACLPermitAllProto(123L, "2", MAC_ADDRESS, false, HOST_ADDRESS, 1);
verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(2)).submit();
verify(commitFuture, times(2)).get(); // 1 + 1 above
*/
@Test
public void testEgressACLTcpSyn() throws Exception {
- egressAclService.egressACLTcpSyn(Long.valueOf(123), "2", MAC_ADDRESS, true, 1, 1);
+ egressAclService.egressACLTcpSyn(123L, "2", MAC_ADDRESS, true, 1, 1);
verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), anyBoolean());
verify(writeTransaction, times(1)).submit();
verify(commitFuture, times(1)).get();
- egressAclService.egressACLTcpSyn(Long.valueOf(123), "2", MAC_ADDRESS, false, 1, 1);
+ egressAclService.egressACLTcpSyn(123L, "2", MAC_ADDRESS, false, 1, 1);
verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(2)).submit();
verify(commitFuture, times(2)).get(); // 1 + 1 above
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.Spy;
import org.mockito.invocation.InvocationOnMock;
-import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
-import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
+import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityGroupCacheManger;
import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager;
import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.PipelineOrchestrator;
import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
@Mock private NeutronSecurityGroup securityGroup;
@Mock private NeutronSecurityRule portSecurityRule;
@Mock private SecurityServicesManager securityServices;
+ @Mock private SecurityGroupCacheManger securityGroupCacheManger;
- private List<Neutron_IPs> neutronSrcIpList = new ArrayList<Neutron_IPs>();
- private List<Neutron_IPs> neutronDestIpList = new ArrayList<Neutron_IPs>();
+ private List<Neutron_IPs> neutronSrcIpList = new ArrayList<>();
+ private List<Neutron_IPs> neutronDestIpList = new ArrayList<>();
private Neutron_IPs neutron_ip_src;
private Neutron_IPs neutron_ip_dest_1;
private Neutron_IPs neutron_ip_dest_2;
private static final String DEST_IP_1 = "192.169.0.1";
private static final String DEST_IP_2 = "192.169.0.2";
private static final String SECURITY_GROUP_UUID = "85cc3048-abc3-43cc-89b3-377341426ac5";
+ private static final String PORT_UUID = "95cc3048-abc3-43cc-89b3-377341426ac5";
private static final String SEGMENT_ID = "2";
private static final Long DP_ID_LONG = (long) 1554;
private static final Long LOCAL_PORT = (long) 124;
when(portSecurityRule.getSecurityRuleEthertype()).thenReturn("IPv4");
when(portSecurityRule.getSecurityRuleDirection()).thenReturn("ingress");
- List<NeutronSecurityRule> portSecurityList = new ArrayList<NeutronSecurityRule>();
+ List<NeutronSecurityRule> portSecurityList = new ArrayList<>();
portSecurityList.add(portSecurityRule);
neutron_ip_src = new Neutron_IPs();
when(securityGroup.getSecurityRules()).thenReturn(portSecurityList);
when(securityServices.getVmListForSecurityGroup
- (neutronSrcIpList, SECURITY_GROUP_UUID)).thenReturn(neutronDestIpList);
+ (PORT_UUID, SECURITY_GROUP_UUID)).thenReturn(neutronDestIpList);
}
/* *//**
verify(commitFuture, times(1)).get();
}
*/
+ /**
+ * Test method {@link EgressAclService#programPortSecurityGroup(java.lang.Long, java.lang.String,
+ * java.lang.String, long, org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup,
+ * java.lang.String, boolean)} when portSecurityRule is incomplete
+ */
+ @Test
+ public void testProgramPortSecurityGroupWithIncompleteRule() throws Exception {
+ NeutronSecurityRule portSecurityRule1 = mock(NeutronSecurityRule.class);
+ when(portSecurityRule1.getSecurityRuleEthertype()).thenReturn("IPv4");
+ when(portSecurityRule1.getSecurityRuleDirection()).thenReturn("not_ingress"); // other direction
+
+ NeutronSecurityRule portSecurityRule2 = mock(NeutronSecurityRule.class);
+ when(portSecurityRule2.getSecurityRuleEthertype()).thenReturn(null);
+ when(portSecurityRule2.getSecurityRuleDirection()).thenReturn("ingress");
+
+ NeutronSecurityRule portSecurityRule3 = mock(NeutronSecurityRule.class);
+ when(portSecurityRule3.getSecurityRuleEthertype()).thenReturn("IPv4");
+ when(portSecurityRule3.getSecurityRuleDirection()).thenReturn(null);
+
+ NeutronSecurityRule portSecurityRule4 = mock(NeutronSecurityRule.class);
+ when(portSecurityRule4.getSecurityRuleEthertype()).thenReturn(null);
+ when(portSecurityRule4.getSecurityRuleDirection()).thenReturn(null);
+
+ List<NeutronSecurityRule> portSecurityList = new ArrayList<>();
+ portSecurityList.add(null);
+ portSecurityList.add(portSecurityRule1);
+ portSecurityList.add(portSecurityRule2);
+ portSecurityList.add(portSecurityRule3);
+ portSecurityList.add(portSecurityRule4);
+
+ NeutronSecurityGroup localSecurityGroup = mock(NeutronSecurityGroup.class);
+ when(localSecurityGroup.getSecurityRules()).thenReturn(portSecurityList);
+
+ ingressAclServiceSpy.programPortSecurityGroup(
+ Long.valueOf(1554), "2", MAC_ADDRESS, 124, localSecurityGroup, PORT_UUID, false);
+ }
+
/**
* Test IPv4 add test case.
*/
when(portSecurityRule.getSecurityRulePortMin()).thenReturn(null);
when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn(null);
- ingressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,true);
+ ingressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,true);
verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
verify(writeTransaction, times(1)).submit();
when(portSecurityRule.getSecurityRulePortMin()).thenReturn(null);
when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn(null);
- ingressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,false);
+ ingressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,false);
verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(1)).submit();
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, true);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, true);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
- neutronSrcIpList, false);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup,
+ PORT_UUID, false);
Match match = flowBuilder.getMatch();
EthernetMatch ethMatch = match.getEthernetMatch();
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID,
- MAC_ADDRESS, LOCAL_PORT, securityGroup, neutronSrcIpList, true);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID,
+ MAC_ADDRESS, LOCAL_PORT, securityGroup, PORT_UUID, true);
Match match = flowBuilder.getMatch();
Icmpv4Match icmpv4Match = match.getIcmpv4Match();
Assert.assertEquals(10, icmpv4Match.getIcmpv4Type().shortValue());
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID,
- MAC_ADDRESS, LOCAL_PORT, securityGroup, neutronSrcIpList, false);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID,
+ MAC_ADDRESS, LOCAL_PORT, securityGroup, PORT_UUID, false);
Match match = flowBuilder.getMatch();
Icmpv4Match icmpv4Match = match.getIcmpv4Match();
Assert.assertEquals(20, icmpv4Match.getIcmpv4Type().shortValue());
PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID,
- MAC_ADDRESS, LOCAL_PORT, securityGroup, neutronSrcIpList, true);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID,
+ MAC_ADDRESS, LOCAL_PORT, securityGroup, PORT_UUID, true);
Match match = flowBuilder.getMatch();
Icmpv4Match icmpv4Match =match.getIcmpv4Match();
Assert.assertEquals(30, icmpv4Match.getIcmpv4Type().shortValue());
PowerMockito.doAnswer(answer())
.when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class), any(NodeBuilder.class));
- ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID,
- MAC_ADDRESS, LOCAL_PORT, securityGroup, neutronSrcIpList, false);
+ ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID,
+ MAC_ADDRESS, LOCAL_PORT, securityGroup, PORT_UUID, false);
Match match = flowBuilder.getMatch();
Icmpv4Match icmpv4Match = match.getIcmpv4Match();
Assert.assertEquals(40, icmpv4Match.getIcmpv4Type().shortValue());
public void testProgramPortSecurityACLRuleInvalidEther() throws Exception {
when(portSecurityRule.getSecurityRuleEthertype()).thenReturn("IPV6");
- ingressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,false);
+ ingressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,false);
verify(writeTransaction, times(0)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(0)).submit();
public void testProgramPortSecurityACLRuleInvalidDirection() throws Exception {
when(portSecurityRule.getSecurityRuleDirection()).thenReturn("edgress");
- ingressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,false);
+ ingressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,false);
verify(writeTransaction, times(0)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(0)).submit();
*/
@Test
public void testProgramFixedSecurityACLAdd1() throws Exception {
- ingressAclServiceSpy.programFixedSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 1, false, false, true);
+ ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, false, false, true);
verify(writeTransaction, times(0)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
verify(writeTransaction, times(0)).submit();
@Test
public void testProgramFixedSecurityACLRemove1() throws Exception {
- ingressAclServiceSpy.programFixedSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 1, false, false, false);
+ ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, false, false, false);
verify(writeTransaction, times(0)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(0)).submit();
*/
@Test
public void testIgressACLDefaultTcpDrop() throws Exception {
- ingressAclService.ingressACLDefaultTcpDrop(Long.valueOf(123), SEGMENTATION_ID, MAC_ADDRESS, PRIORITY, true);
+ ingressAclService.ingressACLDefaultTcpDrop(123L, SEGMENTATION_ID, MAC_ADDRESS, PRIORITY, true);
verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), anyBoolean());
verify(writeTransaction, times(1)).submit();
verify(commitFuture, times(1)).get();
- ingressAclService.ingressACLDefaultTcpDrop(Long.valueOf(123), SEGMENTATION_ID, MAC_ADDRESS, PRIORITY, false);
+ ingressAclService.ingressACLDefaultTcpDrop(123L, SEGMENTATION_ID, MAC_ADDRESS, PRIORITY, false);
verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(2)).submit();
verify(commitFuture, times(2)).get(); // 1 + 1 above
*/
@Test
public void testIngressACLTcpPortWithPrefix() throws Exception {
- ingressAclService.ingressACLTcpPortWithPrefix(Long.valueOf(123), SEGMENTATION_ID, MAC_ADDRESS, true, 1, HOST_ADDRESS, PRIORITY);
+ ingressAclService.ingressACLTcpPortWithPrefix(123L, SEGMENTATION_ID, MAC_ADDRESS, true, 1, HOST_ADDRESS, PRIORITY);
verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), anyBoolean());
verify(writeTransaction, times(1)).submit();
verify(commitFuture, times(1)).get();
- ingressAclService.ingressACLTcpPortWithPrefix(Long.valueOf(123), SEGMENTATION_ID, MAC_ADDRESS, false, 1, HOST_ADDRESS, PRIORITY);
+ ingressAclService.ingressACLTcpPortWithPrefix(123L, SEGMENTATION_ID, MAC_ADDRESS, false, 1, HOST_ADDRESS, PRIORITY);
verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(2)).submit();
verify(commitFuture, times(2)).get(); // 1 + 1 above
*/
@Test
public void testIngressAllowProto() throws Exception {
- ingressAclService.handleIngressAllowProto(Long.valueOf(123), SEGMENTATION_ID, MAC_ADDRESS, true, HOST_ADDRESS, PRIORITY);
+ ingressAclService.handleIngressAllowProto(123L, SEGMENTATION_ID, MAC_ADDRESS, true, HOST_ADDRESS, PRIORITY);
verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), anyBoolean());
verify(writeTransaction, times(1)).submit();
verify(commitFuture, times(1)).get();
- ingressAclService.handleIngressAllowProto(Long.valueOf(123), SEGMENTATION_ID, MAC_ADDRESS, false, HOST_ADDRESS, PRIORITY);
+ ingressAclService.handleIngressAllowProto(123L, SEGMENTATION_ID, MAC_ADDRESS, false, HOST_ADDRESS, PRIORITY);
verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(2)).submit();
verify(commitFuture, times(2)).get(); // 1 + 1 above
*/
@Test
public void testIngressACLPermitAllProto() throws Exception {
- ingressAclService.ingressACLPermitAllProto(Long.valueOf(123), SEGMENTATION_ID, MAC_ADDRESS, true, HOST_ADDRESS, PRIORITY);
+ ingressAclService.ingressACLPermitAllProto(123L, SEGMENTATION_ID, MAC_ADDRESS, true, HOST_ADDRESS, PRIORITY);
verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), anyBoolean());
verify(writeTransaction, times(1)).submit();
verify(commitFuture, times(1)).get();
- ingressAclService.ingressACLPermitAllProto(Long.valueOf(123), SEGMENTATION_ID, MAC_ADDRESS, false, HOST_ADDRESS, PRIORITY);
+ ingressAclService.ingressACLPermitAllProto(123L, SEGMENTATION_ID, MAC_ADDRESS, false, HOST_ADDRESS, PRIORITY);
verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(2)).submit();
verify(commitFuture, times(2)).get(); // 1 + 1 above
*/
@Test
public void testIngressACLTcpSyn() throws Exception {
- ingressAclService.ingressACLTcpSyn(Long.valueOf(123), SEGMENTATION_ID, MAC_ADDRESS, true, 1, PRIORITY);
+ ingressAclService.ingressACLTcpSyn(123L, SEGMENTATION_ID, MAC_ADDRESS, true, 1, PRIORITY);
verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), anyBoolean());
verify(writeTransaction, times(1)).submit();
verify(commitFuture, times(1)).get();
- ingressAclService.ingressACLTcpSyn(Long.valueOf(123), SEGMENTATION_ID, MAC_ADDRESS, false, 1, PRIORITY);
+ ingressAclService.ingressACLTcpSyn(123L, SEGMENTATION_ID, MAC_ADDRESS, false, 1, PRIORITY);
verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(2)).submit();
verify(commitFuture, times(2)).get(); // 1 + 1 above
private static final String SEGMENTATION_ID = "2";
private static final String MAC_ADDRESS = "87:1D:5E:02:40:B8";
- private static final Long DPID = Long.valueOf(122);
- private static final Long LOCAL_PORT = Long.valueOf(451);
- private static final Long ETH_PORT = Long.valueOf(564);
- private static final Long OF_PORT_OUT = Long.valueOf(5698);
+ private static final Long DPID = 122L;
+ private static final Long LOCAL_PORT = 451L;
+ private static final Long ETH_PORT = 564L;
+ private static final Long OF_PORT_OUT = 5698L;
@Before
public void setUp() throws Exception {
when(member.getMAC()).thenReturn(MAC_ADDRESS);
Southbound southbound = mock(Southbound.class);
- when(southbound.getDataPathId(any(Node.class))).thenReturn(Long.valueOf(123));
+ when(southbound.getDataPathId(any(Node.class))).thenReturn(123L);
MemberModifier.field(LoadBalancerService.class, "southbound").set(loadBalancerService, southbound);
}
/**
<version>1.2.1-SNAPSHOT</version>
<packaging>bundle</packaging>
+ <properties>
+ <sfc.project.version>0.2.0-SNAPSHOT</sfc.project.version>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.opendaylight.mdsal.model</groupId>
<groupId>org.opendaylight.mdsal.model</groupId>
<artifactId>yang-ext</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.sfc</groupId>
+ <artifactId>sfc-model</artifactId>
+ <version>${sfc.project.version}</version>
+ </dependency>
</dependencies>
<build>
<configuration>
<instructions>
<Export-Package>
- org.opendaylight.yang.gen.v1.*;
+ org.opendaylight.yang.gen.v1.*,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.acl.rev150105,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.rev150105,
</Export-Package>
- <!--<Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>-->
</instructions>
</configuration>
</plugin>
+++ /dev/null
-module ietf-acl {
- yang-version 1;
-
- namespace "urn:ietf:params:xml:ns:yang:ietf-acl";
-
- prefix acl;
-
- import ietf-yang-types {
- prefix "ietf";
- }
-
- import packet-fields {
- prefix "packet-fields";
- }
-
- organization
- "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
- contact
- "WG Web: http://tools.ietf.org/wg/netmod/
- WG List: netmod@ietf.org
-
- WG Chair: Juergen Schoenwaelder
- j.schoenwaelder@jacobs-university.de
-
- WG Chair: Tom Nadeau
- tnadeau@lucidvision.com
-
- Editor: Dean Bogdanovic
- deanb@juniper.net
-
- Editor: Kiran Agrahara Sreenivasa
- kkoushik@brocade.com
-
- Editor: Lisa Huang
- yihuan@cisco.com
-
- Editor: Dana Blair
- dblair@cisco.com";
-
- description
- "This YANG module defines a component that describing the
- configuration of Access Control Lists (ACLs).";
-
- revision 2014-10-10 {
- description "Creating base model for netmod.";
- reference
- "RFC 6020: YANG - A Data Modeling Language for the
- Network Configuration Protocol (NETCONF)";
- }
-
- identity acl-base {
- description "Base acl type for all ACL type identifiers.";
- }
-
- identity ip-acl {
- base "acl:acl-base";
- description "layer 3 ACL type";
- }
- identity eth-acl {
- base "acl:acl-base";
- description "layer 2 ACL type";
- }
-
- typedef acl-type {
- type identityref {
- base "acl-base";
- }
- description
- "This type is used to refer to an Access Control List
- (ACL) type";
- }
-
- typedef acl-ref {
- type leafref {
- path "/acl:access-lists/acl:access-list/acl:acl-name";
- }
- description "This type is used by data models that
- need to referenced an acl";
- }
-
- container access-lists {
- description
- "Access control lists.";
-
- list access-list {
- key acl-name;
- description "
- An access list (acl) is an ordered list of
- access list entries (ace). Each ace has a
- sequence number to define the order, list
- of match criteria, and a list of actions.
- Since there are several kinds of acls
- implementeded with different attributes for
- each and different for each vendor, this
- model accomodates customizing acls for
- each kind and for each vendor.
- ";
-
- leaf acl-name {
- type string;
- description "The name of access-list.
- A device MAY restrict the length and value of
- this name, possibly space and special
- characters are not allowed.";
- }
-
- leaf acl-type {
- type acl-type;
- description "Type of ACL";
- }
-
- container acl-oper-data {
- config false;
-
- description "Overall ACL operational data";
- leaf match-counter {
- type ietf:counter64;
- description "Total match count for ACL";
- }
-
- leaf-list targets {
- type string;
- description "List of targets where ACL is applied";
- }
- }
-
- container access-list-entries {
- description "The access-list-entries container contains
- a list of access-list-entry(ACE).";
-
- list access-list-entry {
- key rule-name;
- ordered-by user;
-
- description "List of access list entries(ACE)";
- leaf rule-name {
- type string;
- description "Entry name.";
- }
-
- container matches {
- description "Define match criteria";
- choice ace-type {
- description "Type of ace.";
- case ace-ip {
- uses packet-fields:acl-ip-header-fields;
- choice ace-ip-version {
- description "Choice of IP version.";
- case ace-ipv4 {
- uses packet-fields:acl-ipv4-header-fields;
- }
- case ace-ipv6 {
- uses packet-fields:acl-ipv6-header-fields;
- }
- }
- }
- case ace-eth {
- uses packet-fields:acl-eth-header-fields;
- }
- }
- uses packet-fields:metadata;
- }
-
- container actions {
- description "Define action criteria";
- choice packet-handling {
- default deny;
-
- description "Packet handling action.";
- case deny {
- leaf deny {
- type empty;
- description "Deny action.";
- }
- }
- case permit {
- leaf permit {
- type empty;
- description "Permit action.";
- }
- }
- }
- }
-
- container ace-oper-data {
- config false;
-
- description "Per ace operational data";
- leaf match-counter {
- type ietf:counter64;
- description "Number of matches for an ace";
- }
- }
- }
- }
- }
- }
-}
namespace "urn:opendaylight:params:xml:ns:yang:netvirt:sfc:acl";
prefix "acl";
- import ietf-acl { prefix ietf-acl;}
+ import ietf-access-control-list { prefix ietf-acl;}
import yang-ext { prefix ext; }
revision "2015-01-05" {
description "Initial revision of netvirt extensions to ietf-acl model";
}
- // TODO: Add choice for Neutron and add fields there instead of at the root of matches
- augment "/ietf-acl:access-lists/ietf-acl:access-list/ietf-acl:access-list-entries" +
- "/ietf-acl:access-list-entry/ietf-acl:matches" {
+ //augment "/ietf-acl:access-lists/ietf-acl:access-list/ietf-acl:access-list-entries/ietf-acl:access-list-entry/ietf-acl:matches" {
+ augment "/ietf-acl:access-lists/ietf-acl:acl/ietf-acl:access-list-entries/ietf-acl:ace/ietf-acl:matches" {
description "Neutron network uuid";
+ ext:augment-identifier "neutron-network";
leaf network-uuid {
type string;
}
}
- // TODO: Add choice for Neutron and add fields there instead of at the root of matches
- augment "/ietf-acl:access-lists/ietf-acl:access-list/ietf-acl:access-list-entries" +
- "/ietf-acl:access-list-entry/ietf-acl:actions" {
- description "Redirect traffic to SFC identified by SFC Path ID";
- leaf redirect-sfc {
+ augment "/ietf-acl:access-lists/ietf-acl:acl/ietf-acl:access-list-entries/ietf-acl:ace/ietf-acl:actions" {
+ description "Redirect traffic to SFC identified by either SFC, SFP or RSP";
+ ext:augment-identifier "redirect-to-sfc";
+ leaf sfc-name {
+ type string;
+ }
+ leaf sfp-name {
+ type string;
+ }
+ leaf rsp-name {
type string;
}
}
}
}
}
+ container bridges {
+ list bridge {
+ key "name";
+ leaf name {
+ type string;
+ }
+ leaf direction {
+ type enumeration {
+ enum ingress;
+ enum egress;
+ }
+ }
+ }
+ }
}
}
}
+++ /dev/null
-module packet-fields {
- yang-version 1;
-
- namespace "urn:ietf:params:xml:ns:yang:packet-fields";
-
- prefix packet-fields;
-
- import ietf-inet-types {
- prefix "inet";
- }
-
- import ietf-yang-types {
- prefix "yang";
- }
-
- revision 2014-06-25 {
- description "Initial version of packet fields used by access-lists";
- }
-
- grouping acl-transport-header-fields {
- description "Transport header fields";
-
- container source-port-range {
- description "inclusive range of source ports";
- leaf lower-port {
- mandatory true;
- type inet:port-number;
- }
- leaf upper-port {
- type inet:port-number;
- }
- }
-
- container destination-port-range {
- description "inclusive range of destination ports";
- leaf lower-port {
- mandatory true;
- type inet:port-number;
- }
- leaf upper-port {
- type inet:port-number;
- }
- }
- }
-
- grouping acl-ip-header-fields {
- description "Header fields common to ipv4 and ipv6";
-
- uses acl-transport-header-fields;
-
- leaf dscp {
- type inet:dscp;
- }
-
- leaf ip-protocol {
- type uint8;
- }
-
- }
-
- grouping acl-ipv4-header-fields {
- description "fields in IPv4 header";
-
- leaf destination-ipv4-address {
- type inet:ipv4-prefix;
- }
-
- leaf source-ipv4-address {
- type inet:ipv4-prefix;
- }
-
- }
-
- grouping acl-ipv6-header-fields {
- description "fields in IPv6 header";
-
- leaf destination-ipv6-address {
- type inet:ipv6-prefix;
- }
-
- leaf source-ipv6-address {
- type inet:ipv6-prefix;
- }
-
- leaf flow-label {
- type inet:ipv6-flow-label;
- }
-
- }
-
- grouping acl-eth-header-fields {
- description "fields in ethernet header";
-
- leaf destination-mac-address {
- type yang:mac-address;
- }
-
- leaf destination-mac-address-mask {
- type yang:mac-address;
- }
-
- leaf source-mac-address {
- type yang:mac-address;
- }
-
- leaf source-mac-address-mask {
- type yang:mac-address;
- }
- }
-
- grouping timerange {
- description "Define time range entries to restrict
- the access. The time range is identified by a name
- and then referenced by a function, so that those
- time restrictions are imposed on the function itself.";
-
- container absolute {
- description
- "Absolute time and date that
- the associated function starts
- going into effect.";
-
- leaf start {
- type yang:date-and-time;
- description
- "Start time and date";
- }
- leaf end {
- type yang:date-and-time;
- description "Absolute end time and date";
- }
- leaf active {
- type boolean;
- default "true";
- description
- "Specify the associated function
- active or inactive state when
- starts going into effect";
- }
- } // container absolute
- } //grouping timerange
-
- grouping metadata {
- description "Fields associated with a packet but not in the header";
-
- leaf input-interface {
- description "Packet was received on this interface";
- type string;
- }
- uses timerange;
- }
-}
<type>xml</type>
</dependency>
<dependency>
- <groupId>org.opendaylight.sfc</groupId>
- <artifactId>features-sfc</artifactId>
- <version>${sfc.version}</version>
+ <groupId>org.opendaylight.openflowplugin</groupId>
+ <artifactId>features-openflowplugin-extension</artifactId>
+ <version>${openflowplugin.version}</version>
<classifier>features</classifier>
<type>xml</type>
- <scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.sfc</groupId>
- <artifactId>features-sfc-ovs</artifactId>
+ <artifactId>features-sfc</artifactId>
<version>${sfc.version}</version>
<classifier>features</classifier>
<type>xml</type>
<features name="odl-ovsdb-sfc-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
- <repository>mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.dlux/features-dlux/${dlux.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.mdsal.model/features-mdsal-model/${mdsal.model.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.netconf/features-restconf/${restconf.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin/${openflowplugin.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.ovsdb/features-ovsdb/${project.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.ovsdb/southbound-features/${project.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.sfc/features-sfc/${sfc.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.sfc/features-sfc-ovs/${sfc.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features</repository>
+ <repository>mvn:org.opendaylight.controller/features-mdsal/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.dlux/features-dlux/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.mdsal.model/features-mdsal-model/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.netconf/features-restconf/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin-extension/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.ovsdb/features-ovsdb/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.ovsdb/southbound-features/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.sfc/features-sfc/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.yangtools/features-yangtools/{{VERSION}}/xml/features</repository>
<feature name='odl-ovsdb-sfc-api' version='${project.version}' description='OpenDaylight :: ovsdb-sfc :: api'>
<feature version='${mdsal.model.version}'>odl-mdsal-models</feature>
- <bundle>mvn:org.opendaylight.ovsdb/openstack.net-virt-sfc-api/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.ovsdb/openstack.net-virt-sfc-api/{{VERSION}}</bundle>
</feature>
<feature name='odl-ovsdb-sfc' version='${project.version}' description='OpenDaylight :: ovsdb-sfc'>
<feature version='${mdsal.version}'>odl-mdsal-broker</feature>
<feature version="${openflowplugin.version}">odl-openflowplugin-nsf-model</feature>
+ <feature version="${openflowplugin.version}">odl-openflowplugin-flow-services</feature>
+ <feature version='${openflowplugin.version}'>odl-openflowplugin-nxm-extensions</feature>
<feature version='${project.version}'>odl-ovsdb-southbound-impl</feature>
<feature version='${project.version}'>odl-ovsdb-openstack</feature>
- <feature version='${sfc.version}'>odl-sfc-core</feature>
- <feature version='${sfc.version}'>odl-sfc-ovs</feature>
- <feature version="${openflowplugin.version}">odl-openflowplugin-flow-services</feature>
+ <feature version='${sfc.version}'>odl-sfc-provider</feature>
+ <feature version='${sfc.version}'>odl-sfcofl2</feature>
<feature version='${project.version}'>odl-ovsdb-sfc-api</feature>
- <bundle>mvn:org.opendaylight.ovsdb/utils.mdsal-utils/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.ovsdb/utils.servicehelper/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.ovsdb/openstack.net-virt-sfc-impl/${project.version}</bundle>
- <configfile finalname="${configfile.directory}/openstack.net-virt-sfc.xml">mvn:org.opendaylight.ovsdb/openstack.net-virt-sfc-impl/${project.version}/xml/config</configfile>
+ <bundle>mvn:org.opendaylight.ovsdb/utils.mdsal-utils/{{VERSION}}</bundle>
+ <bundle>mvn:org.opendaylight.ovsdb/utils.servicehelper/{{VERSION}}</bundle>
+ <bundle>mvn:org.opendaylight.ovsdb/openstack.net-virt-sfc-impl/{{VERSION}}</bundle>
+ <configfile finalname="${configfile.directory}/openstack.net-virt-sfc.xml">mvn:org.opendaylight.ovsdb/openstack.net-virt-sfc-impl/{{VERSION}}/xml/config</configfile>
</feature>
<feature name='odl-ovsdb-sfc-rest' version='${project.version}' description='OpenDaylight :: ovsdb-sfc :: REST'>
<feature version="${project.version}">odl-ovsdb-sfc</feature>
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<repository>mvn:org.opendaylight.ovsdb/openstack.net-virt-sfc-features/1.2.1-SNAPSHOT/xml/features</repository>
<feature name='odl-ovsdb-sfc-test' version='${project.version}' description='OpenDaylight :: ovsdb-sfc-test'>
- <bundle>mvn:org.opendaylight.ovsdb/utils.mdsal-utils/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.ovsdb/utils.southbound-utils/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.ovsdb/utils.mdsal-utils/{{VERSION}}</bundle>
+ <bundle>mvn:org.opendaylight.ovsdb/utils.southbound-utils/{{VERSION}}</bundle>
<feature version='${project.version}'>odl-ovsdb-sfc-ui</feature>
</feature>
</features>
<properties>
<networkconfig.neutron.version>0.6.0-SNAPSHOT</networkconfig.neutron.version>
<openflowplugin.version>0.2.0-SNAPSHOT</openflowplugin.version>
+ <powermock.version>1.5.2</powermock.version>
<sonar.jacoco.itReportPath>../it/target/jacoco-it.exec</sonar.jacoco.itReportPath>
<sfc.project.version>0.2.0-SNAPSHOT</sfc.project.version>
</properties>
<artifactId>openstack.net-virt-providers</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>southbound-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>southbound-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>utils.mdsal-utils</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-common-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.model</groupId>
+ <artifactId>model-inventory</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.openflowplugin</groupId>
+ <artifactId>openflowplugin-extension-nicira</artifactId>
+ <version>${openflowplugin.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.openflowplugin</groupId>
+ <artifactId>openflowjava-extension-nicira</artifactId>
+ <version>${openflowplugin.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.openflowplugin.model</groupId>
<artifactId>model-flow-base</artifactId>
<artifactId>sfc-model</artifactId>
<version>${sfc.project.version}</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.sfc</groupId>
- <artifactId>sfc-ovs</artifactId>
- <version>${sfc.project.version}</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.sfc</groupId>
<artifactId>sfc-provider</artifactId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-core</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.codehaus.sonar-plugins.java</groupId>
<artifactId>sonar-jacoco-listeners</artifactId>
<version>${sonar-jacoco-listeners.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal.model</groupId>
+ <artifactId>iana-if-type-2014-05-08</artifactId>
+ <version>2014.05.08.8-SNAPSHOT</version>
+ </dependency>
</dependencies>
<build>
</instructions>
</configuration>
</plugin>
- <plugin>
+ <!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
- <propertyExpansion>checkstyle.checker.severity=error</propertyExpansion>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
</configuration>
- </plugin>
+ </plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<module>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:netvirt:sfc">prefix:netvirt-sfc</type>
<name>netvirt-sfc-default</name>
+ <of13provider>workaround</of13provider>
<broker>
<type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
<name>binding-osgi-broker</name>
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.INetvirtSfcOF13Provider;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13;
+package org.opendaylight.ovsdb.openstack.netvirt.sfc;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.AccessList;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.workaround.services.SfcClassifierService;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.Acl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.Bridges;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.bridges.Bridge;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.Sff;
+import org.osgi.framework.ServiceReference;
/**
* Open vSwitch OpenFlow 1.3 Networking Provider for Netvirt SFC
* Method installs the OF rules corresponding to rules within ACL
* on a given Service Function Forwarder. DataObject which is identified by InstanceIdentifier.
*
- * @param sff - Service Function Forwarder
+ * @param bridge - Service Function Forwarder
* @param acl - Access list includes rules that need to be installed in a SFF.
*/
- public void addClassifierRules(Sff sff, AccessList acl);
+ void addClassifierRules(Bridge bridge, Acl acl);
+ void addClassifierRules(Bridges bridges, Acl acl);
/**
* Method removes the OF rules corresponding to rules within ACL
* @param sff - Service Function Forwarder
* @param acl - Access list includes rules that need to be installed in a SFF.
*/
- public void removeClassifierRules(Sff sff, AccessList acl);
+ void removeClassifierRules(Sff sff, Acl acl);
+
+ void addClassifierRules(Acl acl);
+ void removeClassifierRules(Acl acl);
+
+ void setSfcClassifierService(ISfcClassifierService sfcClassifierService);
+ public void setDependencies(ServiceReference serviceReference);
}
--- /dev/null
+/*
+ * Copyright © 2015 Red Hat, 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.ovsdb.openstack.netvirt.sfc;
+
+import java.net.InetAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.Matches;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+
+public interface ISfcClassifierService {
+ void programIngressClassifier(long dataPathId, String ruleName, Matches matches,
+ NshUtils nshHeader, long vxGpeOfPort, boolean write);
+
+ void programSfcTable(long dataPathId, long vxGpeOfPort, short goToTableId, boolean write);
+
+ void programEgressClassifier1(long dataPathId, long vxGpeOfPort, long nsp, short nsi,
+ int tunnelOfPort, int tunnelId, short gotoTableId, boolean write);
+
+ void programEgressClassifier(long dataPathId, long vxGpeOfPort, long nsp, short nsi,
+ long sfOfPort, int tunnelId, boolean write);
+
+ void programEgressClassifierBypass(long dataPathId, long vxGpeOfPort, long nsp, short nsi,
+ long sfOfPort, int tunnelId, boolean write);
+
+ void program_sfEgress(long dataPathId, int dstPort, boolean write);
+
+ void program_sfIngress(long dataPathId, int dstPort, long sfOfPort,
+ String ipAddress, String sfDplName, boolean write);
+
+ void programStaticArpEntry(long dataPathId, long ofPort, String macAddressStr,
+ String ipAddress, boolean write);
+}
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.INetvirtSfcOF13Provider;
import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.AccessLists;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.AccessList;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.AccessListKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.AccessListEntries;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.AccessListEntry;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.AccessListEntryKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.Classifiers;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.Classifier;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.Sff;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.AccessLists;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.Acl;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
/**
* Data tree listener for AccessList.
*/
-public class NetvirtSfcAclListener extends AbstractDataTreeListener<AccessList> {
+public class NetvirtSfcAclListener extends AbstractDataTreeListener<Acl> {
private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcAclListener.class);
private ListenerRegistration<NetvirtSfcAclListener> listenerRegistration;
- private MdsalUtils dbutils;
/**
* {@link NetvirtSfcAclListener} constructor.
* @param db MdSal {@link DataBroker}
*/
public NetvirtSfcAclListener(final INetvirtSfcOF13Provider provider, final DataBroker db) {
- super(provider, AccessList.class);
+ super(provider, Acl.class);
Preconditions.checkNotNull(db, "DataBroker can not be null!");
- dbutils = new MdsalUtils(db);
registrationListener(db);
}
private void registrationListener(final DataBroker db) {
- final DataTreeIdentifier<AccessList> treeId =
+ final DataTreeIdentifier<Acl> treeId =
new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getIetfAclIid());
try {
- LOG.info("Registering Data Change Listener for Netvirt AccesList configuration.");
+ LOG.info("Registering Data Change Listener for NetvirtSfc AccessList configuration.");
listenerRegistration = db.registerDataTreeChangeListener(treeId, this);
} catch (final Exception e) {
LOG.warn("Netvirt AccesList DataChange listener registration fail!");
- LOG.debug("Netvirt AccesList DataChange listener registration fail!", e);
- throw new IllegalStateException("NetvirtSfcAccesListListener startup fail! System needs restart.", e);
+ throw new IllegalStateException("NetvirtSfcAccessListListener startup fail! System needs restart.", e);
}
}
}
@Override
- public void remove(final InstanceIdentifier<AccessList> identifier,
- final AccessList removeDataObj) {
+ public void remove(final InstanceIdentifier<Acl> identifier,
+ final Acl removeDataObj) {
Preconditions.checkNotNull(removeDataObj, "Removed object can not be null!");
- String aclName = removeDataObj.getAclName();
-
- Classifiers classifiers = dbutils.read(LogicalDatastoreType.CONFIGURATION, getClassifierIid());
- if (classifiers != null) {
- for (Classifier classifier : classifiers.getClassifier()) {
- if (classifier.getAcl().equalsIgnoreCase(aclName)) {
- if (classifier.getSffs() != null) {
- for (Sff sff : classifier.getSffs().getSff()) {
- provider.removeClassifierRules(sff, removeDataObj);
- }
- }
- }
- }
- }
+ provider.removeClassifierRules(removeDataObj);
}
@Override
- public void update(final InstanceIdentifier<AccessList> identifier,
- final AccessList original, final AccessList update) {
+ public void update(final InstanceIdentifier<Acl> identifier,
+ final Acl original, final Acl update) {
}
@Override
- public void add(final InstanceIdentifier<AccessList> identifier,
- final AccessList addDataObj) {
+ public void add(final InstanceIdentifier<Acl> identifier,
+ final Acl addDataObj) {
Preconditions.checkNotNull(addDataObj, "Added object can not be null!");
- String aclName = addDataObj.getAclName();
- LOG.debug("Adding accesslist = {}", identifier);
- Classifiers classifiers = dbutils.read(LogicalDatastoreType.CONFIGURATION, getClassifierIid());
- if (classifiers != null) {
- for (Classifier classifier : classifiers.getClassifier()) {
- if (classifier.getAcl().equalsIgnoreCase(aclName)) {
- if (classifier.getSffs() != null) {
- for (Sff sff : classifier.getSffs().getSff()) {
- provider.addClassifierRules(sff, addDataObj);
- }
- }
- }
- }
- }
+ LOG.debug("Adding accesslist iid = {}, dataObj = {}", identifier, addDataObj);
+ provider.addClassifierRules(addDataObj);
}
- private InstanceIdentifier<Classifiers> getClassifierIid() {
- return InstanceIdentifier.create(Classifiers.class);
- }
-
- public InstanceIdentifier<AccessList> getIetfAclIid() {
- return InstanceIdentifier.create(AccessLists.class).child(AccessList.class);
- }
-
- /**
- * Create an {@link AccessListEntry} {@link InstanceIdentifier}.
- * @param aclName is the name of the ACL
- * @param ruleName is the name of the rule
- * @return the {@link AccessListEntry} {@link InstanceIdentifier}
- */
- public InstanceIdentifier<AccessListEntry> getIetfAclEntryIid(String aclName, String ruleName) {
- return InstanceIdentifier.create(AccessLists.class).child(AccessList.class,
- new AccessListKey(aclName)).child(AccessListEntries.class).child(AccessListEntry.class,
- new AccessListEntryKey(ruleName));
+ public InstanceIdentifier<Acl> getIetfAclIid() {
+ return InstanceIdentifier.create(AccessLists.class).child(Acl.class);
}
}
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.INetvirtSfcOF13Provider;
import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.AccessLists;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.AccessList;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.AccessListKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.AccessLists;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.Acl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.AclKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.Classifiers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.Classifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.Sff;
*/
public class NetvirtSfcClassifierListener extends AbstractDataTreeListener<Classifier> {
private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcClassifierListener.class);
- private MdsalUtils dbutils;
+ private MdsalUtils mdsalUtils;
private ListenerRegistration<NetvirtSfcClassifierListener> listenerRegistration;
/**
public NetvirtSfcClassifierListener(final INetvirtSfcOF13Provider provider, final DataBroker db) {
super(provider, Classifier.class);
Preconditions.checkNotNull(db, "DataBroker can not be null!");
- dbutils = new MdsalUtils(db);
+ mdsalUtils = new MdsalUtils(db);
registrationListener(db);
}
final DataTreeIdentifier<Classifier> treeId =
new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getClassifierIid());
try {
- LOG.info("Registering Data Change Listener for Netvirt Classifier configuration.");
+ LOG.info("Registering Data Change Listener for NetvirtSfc Classifier configuration.");
listenerRegistration = db.registerDataTreeChangeListener(treeId, this);
} catch (final Exception e) {
LOG.warn("Netvirt Classifier DataChange listener registration fail!");
- LOG.debug("Netvirt Classifier DataChange listener registration fail!", e);
throw new IllegalStateException("NetvirtSfcClassifierListener startup fail! System needs restart.", e);
}
}
listenerRegistration.close();
} catch (final Exception e) {
LOG.warn("Error to stop Netvirt Classifier DataChange listener: {}", e.getMessage());
- LOG.debug("Error to stop Netvirt Classifier DataChange listener..", e);
}
listenerRegistration = null;
}
Preconditions.checkNotNull(removeDataObj, "Added object can not be null!");
String aclName = removeDataObj.getAcl();
// Read the ACL information from data store and make sure it exists.
- AccessList acl = dbutils.read(LogicalDatastoreType.CONFIGURATION,getIetfAclIid(aclName));
+ Acl acl = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, getIetfAclIid(aclName));
if (acl == null) {
LOG.debug("IETF ACL with name ={} is not yet configured. skip this operation", aclName);
return;
}
- if (removeDataObj.getSffs() != null) {
- for (Sff sff : removeDataObj.getSffs().getSff()) {
- // Netvirt classifier binds an ACL with service function forwarder that is identified by SFF name.
- // SFF validation can be done with SFC Provider APIs, as SFF is configured within SFC project.
- // Netvirt SFC provider will validate the SFF using SFC provider APIs.
- provider.removeClassifierRules(sff, acl);
- }
- }
+ provider.removeClassifierRules(acl);
}
@Override
final Classifier addDataObj) {
Preconditions.checkNotNull(addDataObj, "Added object can not be null!");
String aclName = addDataObj.getAcl();
+ LOG.debug("Adding classifier iid = {}, dataObj = {}", identifier, addDataObj);
// Read the ACL information from data store and make sure it exists.
- AccessList acl = dbutils.read(LogicalDatastoreType.CONFIGURATION,getIetfAclIid(aclName));
+ Acl acl = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, getIetfAclIid(aclName));
if (acl == null) {
LOG.debug("IETF ACL with name ={} is not yet configured. skip this operation", aclName);
return;
}
- if (addDataObj.getSffs() != null) {
- for (Sff sff : addDataObj.getSffs().getSff()) {
- // Netvirt classifier binds an ACL with service function forwarder that is identified by SFF name.
- // SFF validation can be done with SFC Provider APIs, as SFF is configured within SFC project.
- // Netvirt SFC provider will validate the SFF using SFC provider APIs.
- provider.addClassifierRules(sff, acl);
- }
- }
+ provider.addClassifierRules(acl);
}
public InstanceIdentifier<Classifier> getClassifierIid() {
return InstanceIdentifier.create(Classifiers.class).child(Classifier.class);
}
- private InstanceIdentifier<AccessList> getIetfAclIid(String aclName) {
- return InstanceIdentifier.create(AccessLists.class).child(AccessList.class, new AccessListKey(aclName));
+ private InstanceIdentifier<Acl> getIetfAclIid(String aclName) {
+ return InstanceIdentifier.create(AccessLists.class).child(Acl.class, new AclKey(aclName));
}
}
package org.opendaylight.ovsdb.openstack.netvirt.sfc;
+import java.util.Dictionary;
+import java.util.Hashtable;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.INetvirtSfcOF13Provider;
-import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.NetvirtSfcOF13Provider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.AbstractServiceInstance;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.OF13Provider;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.standalone.openflow13.NetvirtSfcStandaloneOF13Provider;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.standalone.openflow13.services.SfcClassifierService;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.workaround.NetvirtSfcWorkaroundOF13Provider;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class NetvirtSfcProvider implements BindingAwareProvider, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcProvider.class);
private NetvirtSfcAclListener aclListener;
- private NetvirtSfcClassifierListener classfierListener;
+ private NetvirtSfcClassifierListener classifierListener;
+
+ public void setOf13Provider(String of13Provider) {
+ LOG.info("of13Provider is: {}", of13Provider);
+ this.of13Provider = of13Provider;
+ }
+
+ private String of13Provider;
+
+ public void setBundleContext(BundleContext bundleContext) {
+ LOG.info("bundleContext is: {}", bundleContext);
+ this.bundleContext = bundleContext;
+ }
+
+ private BundleContext bundleContext;
+
+ public NetvirtSfcProvider(BundleContext bundleContext) {
+ LOG.info("NetvirtSfcProvider: bundleContext: {}", bundleContext);
+ this.bundleContext = bundleContext;
+ }
@Override
public void onSessionInitiated(ProviderContext session) {
LOG.info("NetvirtSfcProvider Session Initiated");
DataBroker dataBroker = session.getSALService(DataBroker.class);
- INetvirtSfcOF13Provider provider = new NetvirtSfcOF13Provider(dataBroker);
+ MdsalUtils mdsalUtils = new MdsalUtils(dataBroker);
+ SfcUtils sfcUtils = new SfcUtils(mdsalUtils);
+
+ // Allocate provider based on config
+ INetvirtSfcOF13Provider provider;
+ if (of13Provider.equals("standalone")) {
+ provider = new NetvirtSfcStandaloneOF13Provider(dataBroker);
+ } else {
+ provider = new NetvirtSfcWorkaroundOF13Provider(dataBroker, mdsalUtils, sfcUtils);
+ }
aclListener = new NetvirtSfcAclListener(provider, dataBroker);
- classfierListener = new NetvirtSfcClassifierListener(provider, dataBroker);
+ classifierListener = new NetvirtSfcClassifierListener(provider, dataBroker);
+
+ addToPipeline(provider);
+ provider.setDependencies(null);
}
@Override
public void close() throws Exception {
LOG.info("NetvirtSfcProvider Closed");
aclListener.close();
- classfierListener.close();
+ classifierListener.close();
+ }
+
+ private void addToPipeline(INetvirtSfcOF13Provider provider) {
+ if (provider instanceof NetvirtSfcStandaloneOF13Provider) {
+ SfcClassifierService sfcClassifierService =
+ new org.opendaylight.ovsdb.openstack.netvirt.sfc.standalone.openflow13.services.SfcClassifierService();
+ registerService(bundleContext, ISfcClassifierService.class.getName(),
+ sfcClassifierService, Service.SFC_CLASSIFIER);
+ sfcClassifierService.setDependencies(bundleContext, null);
+ } else {
+ org.opendaylight.ovsdb.openstack.netvirt.sfc.workaround.services.SfcClassifierService sfcClassifierService =
+ new org.opendaylight.ovsdb.openstack.netvirt.sfc.workaround.services.SfcClassifierService();
+ registerService(bundleContext, ISfcClassifierService.class.getName(),
+ sfcClassifierService, Service.SFC_CLASSIFIER);
+ sfcClassifierService.setDependencies(bundleContext, null);
+ }
+
+ //provider.setSfcClassifierService(sfcClassifierService);
+ }
+
+ private ServiceRegistration<?> registerService(BundleContext bundleContext, String[] interfaces,
+ Dictionary<String, Object> properties, Object impl) {
+ ServiceRegistration<?> serviceRegistration = bundleContext.registerService(interfaces, impl, properties);
+ return serviceRegistration;
+ }
+
+ private ServiceRegistration<?> registerService(BundleContext bundleContext, String interfaceClassName,
+ Object impl, Object serviceProperty) {
+ Dictionary<String, Object> properties = new Hashtable<>();
+ properties.put(AbstractServiceInstance.SERVICE_PROPERTY, serviceProperty);
+ properties.put(Constants.PROVIDER_NAME_PROPERTY, OF13Provider.NAME);
+ return registerService(bundleContext,
+ new String[] {AbstractServiceInstance.class.getName(),interfaceClassName},
+ properties, impl);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Dell, 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.ovsdb.openstack.netvirt.sfc;
+
+import com.google.common.net.InetAddresses;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+
+/**
+ * Open Vswitch DB OpenFlow 1.3 Networking Provider for Netvirt SFC Utilities.
+ * @author Arun Yerra
+ */
+public class NshUtils {
+ private Ipv4Address nshTunIpDst;
+ private PortNumber nshTunUdpPort;
+ private long nshNsp;
+ private short nshNsi;
+ private long nshMetaC1;
+ private long nshMetaC2;
+
+ public NshUtils() {
+ super();
+ }
+
+ /**
+ * {@link NshUtils} constructor.
+ * @param nshTunIpDst Tunnel Destination IP
+ * @param nshTunUdpPort Tunnel Transport Port
+ * @param nshNsp Service Path Id
+ * @param nshNsi Service Path Index
+ * @param nshMetaC1 End point ID
+ * @param nshMetaC2 Tunnel Id.
+ */
+ public NshUtils(Ipv4Address nshTunIpDst, PortNumber nshTunUdpPort,
+ long nshNsp, short nshNsi, long nshMetaC1,
+ long nshMetaC2) {
+ super();
+ this.nshTunIpDst = nshTunIpDst;
+ this.nshTunUdpPort = nshTunUdpPort;
+ this.nshNsp = nshNsp;
+ this.nshNsi = nshNsi;
+ this.nshMetaC1 = nshMetaC1;
+ this.nshMetaC2 = nshMetaC2;
+ }
+
+ /*
+ * @return the nshTunIpDst
+ */
+ public Ipv4Address getNshTunIpDst() {
+ return nshTunIpDst;
+ }
+
+ /*
+ * @param nshTunIpDst the nshTunIpDst to set
+ */
+ public void setNshTunIpDst(Ipv4Address nshTunIpDst) {
+ this.nshTunIpDst = nshTunIpDst;
+ }
+
+ /*
+ * @return the nshTunUdpPort
+ */
+ public PortNumber getNshTunUdpPort() {
+ return nshTunUdpPort;
+ }
+
+ /*
+ * @param nshTunUdpPort the nshTunUdpPort to set
+ */
+ public void setNshTunUdpPort(PortNumber nshTunUdpPort) {
+ this.nshTunUdpPort = nshTunUdpPort;
+ }
+
+ /*
+ * @return the nshNsp
+ */
+ public long getNshNsp() {
+ return nshNsp;
+ }
+
+ /*
+ * @param nshNsp the nshNsp to set
+ */
+ public void setNshNsp(long nshNsp) {
+ this.nshNsp = nshNsp;
+ }
+
+ /*
+ * @return the nshNsi
+ */
+ public short getNshNsi() {
+ return nshNsi;
+ }
+
+ /*
+ * @param nshNsi the nshNsi to set
+ */
+ public void setNshNsi(short nshNsi) {
+ this.nshNsi = nshNsi;
+ }
+
+ /*
+ * @return the nshMetaC1
+ */
+ public long getNshMetaC1() {
+ return nshMetaC1;
+ }
+
+ /*
+ * @param nshMetaC1 the nshMetaC1 to set
+ */
+ public void setNshMetaC1(long nshMetaC1) {
+ this.nshMetaC1 = nshMetaC1;
+ }
+
+ /*
+ * @return the nshMetaC2
+ */
+ public long getNshMetaC2() {
+ return nshMetaC2;
+ }
+
+ /*
+ * @param nshMetaC2 the nshMetaC2 to set
+ */
+ public void setNshMetaC2(long nshMetaC2) {
+ this.nshMetaC2 = nshMetaC2;
+ }
+
+ public static Long convertIpAddressToLong(Ipv4Address ipv4Address) {
+ return (InetAddresses.coerceToInteger(InetAddresses.forString(ipv4Address.getValue()))) & 0xFFFFFFFFL;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "NshUtils [nshTunIpDst=" + nshTunIpDst + ", nshTunUdpPort=" + nshTunUdpPort + ", nshNsp=" + nshNsp
+ + ", nshNsi=" + nshNsi + ", nshMetaC1=" + nshMetaC1 + ", nshMetaC2=" + nshMetaC2 + "]";
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2015 Red Hat, 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.ovsdb.openstack.netvirt.sfc;
+
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceFunctionAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServicePathAPI;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.RspName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.RenderedServicePaths;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePathKey;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunctionKey;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPaths;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.data.plane.locator.locator.type.Ip;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.Classifiers;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SfcUtils {
+ private static final Logger LOG = LoggerFactory.getLogger(SfcUtils.class);
+ private MdsalUtils mdsalUtils;
+
+ public SfcUtils(MdsalUtils mdsalUtils) {
+ this.mdsalUtils = mdsalUtils;
+ }
+
+ public InstanceIdentifier<Classifiers> getClassifierIid() {
+ return InstanceIdentifier.create(Classifiers.class);
+ }
+
+ public InstanceIdentifier<RenderedServicePaths> getRspsId() {
+ return InstanceIdentifier.builder(RenderedServicePaths.class).build();
+ }
+
+ public InstanceIdentifier<RenderedServicePath> getRspId(String rspName) {
+ return InstanceIdentifier.builder(RenderedServicePaths.class)
+ .child(RenderedServicePath.class, new RenderedServicePathKey(new RspName(rspName))).build();
+ }
+
+ public InstanceIdentifier<ServiceFunction> getSfId(String sfName) {
+ return InstanceIdentifier.builder(ServiceFunctions.class)
+ .child(ServiceFunction.class, new ServiceFunctionKey(SfName.getDefaultInstance(sfName))).build();
+ }
+
+ public RenderedServicePath getRsp(String rspName) {
+ return mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, getRspId(rspName));
+ }
+
+ public RenderedServicePath getRspforSfp(String sfpName) {
+ RenderedServicePath rspFound = null;
+ RenderedServicePaths rsps = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, this.getRspsId());
+ if (rsps != null) {
+ for (RenderedServicePath rsp : rsps.getRenderedServicePath()) {
+ if (rsp.getParentServiceFunctionPath() != null) {
+ if (rsp.getParentServiceFunctionPath().getValue().equals(sfpName)) {
+ rspFound = rsp;
+ }
+ }
+ }
+ }
+ return rspFound;
+ }
+
+ public ServiceFunctionPath getSfp(String redirectSfc) {
+ ServiceFunctionPath sfpFound = null;
+ ServiceFunctionPaths sfps = SfcProviderServicePathAPI.readAllServiceFunctionPaths();
+ if (sfps != null) {
+ for (ServiceFunctionPath sfp: sfps.getServiceFunctionPath()) {
+ if (sfp.getServiceChainName().getValue().equalsIgnoreCase(redirectSfc)) {
+ sfpFound = sfp;
+ }
+ }
+ }
+ return sfpFound;
+ }
+
+ public IpAddress getSfIpAddress(String sfname) {
+ ServiceFunction serviceFunction =
+ SfcProviderServiceFunctionAPI.readServiceFunction(SfName.getDefaultInstance(sfname));
+
+ if (serviceFunction == null) {
+ LOG.info("Failed to read ServiceFunction: {}", sfname);
+ return null;
+ }
+
+ return getSfIpAddress(serviceFunction);
+ }
+
+ public IpAddress getSfIpAddress(ServiceFunction serviceFunction) {
+ if (serviceFunction == null) {
+ LOG.info("getSfIp: Servicefunction is null");
+ return null;
+ }
+
+ Ip ipLocator = (Ip) serviceFunction.getSfDataPlaneLocator().get(0).getLocatorType();
+ return ipLocator.getIp();
+ }
+
+ public PortNumber getSfPort(ServiceFunction serviceFunction) {
+ if (serviceFunction == null) {
+ LOG.info("getSfIp: Servicefunction is null");
+ return null;
+ }
+
+ Ip ipLocator = (Ip) serviceFunction.getSfDataPlaneLocator().get(0).getLocatorType();
+ return ipLocator.getPort();
+ }
+
+ public Ip getSfIp(ServiceFunction serviceFunction) {
+ if (serviceFunction == null) {
+ LOG.info("getSfIp: Servicefunction is null");
+ return null;
+ }
+
+ return (Ip)serviceFunction.getSfDataPlaneLocator().get(0).getLocatorType();
+ }
+
+ public String getSfDplName(ServiceFunction serviceFunction) {
+ String sfDplName = null;
+ if (serviceFunction == null) {
+ LOG.warn("getSfDplName: Servicefunction is null");
+ return null;
+ }
+
+ sfDplName = serviceFunction.getSfDataPlaneLocator().get(0).getName().getValue();
+ return sfDplName;
+ }
+
+ public Ip getSffIp(ServiceFunctionForwarder serviceFunctionForwarder) {
+ if (serviceFunctionForwarder == null) {
+ LOG.info("getSfIp: ServicefunctionForwarder is null");
+ return null;
+ }
+
+ return (Ip)serviceFunctionForwarder.getSffDataPlaneLocator().get(0).getDataPlaneLocator().getLocatorType();
+ }
+}
+++ /dev/null
-/*
- * Copyright (c) 2015 Dell, 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.ovsdb.openstack.netvirt.sfc.openflow13;
-
-import java.util.Iterator;
-import java.util.List;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
-import org.opendaylight.ovsdb.openstack.netvirt.api.NodeCacheManager;
-import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
-import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.PipelineOrchestrator;
-import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
-import org.opendaylight.ovsdb.utils.mdsal.openflow.InstructionUtils;
-import org.opendaylight.ovsdb.utils.mdsal.openflow.MatchUtils;
-import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
-import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
-import org.opendaylight.sfc.provider.api.SfcProviderServiceForwarderAPI;
-import org.opendaylight.sfc.sfc_ovs.provider.SfcOvsUtil;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.AccessList;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.AccessListEntry;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.access.list.entry.Actions;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.access.list.entry.Matches;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.access.list.entry.actions.packet.handling.Deny;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.access.list.entry.actions.packet.handling.Permit;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.access.list.entry.matches.ace.type.AceEth;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.access.list.entry.matches.ace.type.AceIp;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.access.list.entry.matches.ace.type.ace.ip.ace.ip.version.AceIpv4;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.Sff;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Open vSwitch OpenFlow 1.3 Networking Provider for Netvirt SFC
- * @author Arun Yerra
- */
-public class NetvirtSfcOF13Provider implements INetvirtSfcOF13Provider{
- private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcOF13Provider.class);
- private static final int DEFAULT_FLOW_PRIORITY = 32768;
- private volatile NodeCacheManager nodeCacheManager;
- private volatile Southbound southbound;
- private MdsalUtils dbutils;
- private PipelineOrchestrator orchestrator;
-
- /**
- * {@link NetvirtSfcOF13Provider} constructor.
- * @param dataBroker MdSal {@link DataBroker}
- */
- public NetvirtSfcOF13Provider(final DataBroker dataBroker) {
- Preconditions.checkNotNull(dataBroker, "Input dataBroker cannot be NULL!");
-
- //this.dataService = dataBroker;
- dbutils = new MdsalUtils(dataBroker);
-
- this.setDependencies(null);
- }
-
- @Override
- public void addClassifierRules(Sff sff, AccessList acl) {
- Preconditions.checkNotNull(sff, "Input service function forwarder cannot be NULL!");
- Preconditions.checkNotNull(acl, "Input accesslist cannot be NULL!");
-
- // Validate if any service function forwarder exists by the name, using SFC provider APIs.
- ServiceFunctionForwarder serviceForwarder =
- SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(sff.getName());
- if (serviceForwarder == null) {
- LOG.debug("Service Function Forwarder = {} not yet configured. Skip processing !!", sff.getName());
- return;
- }
-
- // If a service function forwarder exists, then get the corresponding OVS Bridge details and Openflow NodeId.
- // If OVS Bridge augmentation is configured, the following API returns NULL.
- String datapathId = SfcOvsUtil.getOpenFlowNodeIdForSff(serviceForwarder);
- if (datapathId == null) {
- LOG.debug("Service Function Forwarder = {} is not augemented with "
- + "OVS Bridge Information. Skip processing!!", sff.getName());
- }
- // If openflow Node Id is NULL, get all the bridge nodes using southbound apis and fetch
- // SFF with matching name. From this bridge name, get the openflow data path ID.
- if (datapathId == null) {
- Node node = null;
- final List<Node> nodes = nodeCacheManager.getBridgeNodes();
- if (nodes.isEmpty()) {
- LOG.debug("Noop with Classifier Creation on SFF={}. No Bridges configured YET!!", sff.getName());
- } else {
- for (Node dstNode : nodes) {
- LOG.debug("Processing Node={}, sff={}", dstNode.getNodeId().getValue(), sff.getName());
- if (dstNode.getNodeId().getValue().equalsIgnoreCase(sff.getName())) {
- LOG.debug("Found matching OVSDB Bridge Name!!= {}", dstNode.getNodeId().getValue());
- node = dstNode;
- break;
- }
- }
- }
- }
-
- LOG.debug("Processing the Classifier rules on Node={}", datapathId);
- if (datapathId != null) {
- // Program the OF flow on the corresponding open flow node.
- Iterator<AccessListEntry> itr = acl.getAccessListEntries().getAccessListEntry().iterator();
- while (itr.hasNext()) {
- AccessListEntry entry = itr.next();
- programOFRules(entry, datapathId, true);
- }
- }
- }
-
- private void programOFRules(AccessListEntry entry, String datapathId, boolean write) {
- NodeBuilder nodeBuilder = new NodeBuilder();
- nodeBuilder.setId(new NodeId(Constants.OPENFLOW_NODE_PREFIX + datapathId));
- nodeBuilder.setKey(new NodeKey(nodeBuilder.getId()));
-
- //Create the match using match builder, by parsing the Accesslist Entry Match.
- MatchBuilder matchBuilder = null;
- matchBuilder = buildMatch(entry.getRuleName(), entry.getMatches(), datapathId);
-
- InstructionsBuilder isb = null;
- isb = buildActions(entry.getRuleName(), entry.getActions(), datapathId);
-
- String flowId = "NETVIRT_SFC_FLOW" + "_" + entry.getRuleName();
-
- FlowBuilder flowBuilder = new FlowBuilder();
- flowBuilder.setId(new FlowId(flowId));
- FlowKey key = new FlowKey(new FlowId(flowId));
- flowBuilder.setMatch(matchBuilder.build());
- flowBuilder.setPriority(DEFAULT_FLOW_PRIORITY);
- flowBuilder.setBarrier(true);
- flowBuilder.setTableId(this.getTable());
- flowBuilder.setKey(key);
- flowBuilder.setFlowName(flowId);
- flowBuilder.setHardTimeout(0);
- flowBuilder.setIdleTimeout(0);
-
- flowBuilder.setInstructions(isb.build());
-
- if (write) {
- writeFlow(flowBuilder, nodeBuilder);
- } else {
- removeFlow(flowBuilder, nodeBuilder);
- }
- }
-
- private InstructionsBuilder buildActions(String ruleName, Actions actions, String datapathId) {
- InstructionBuilder ib = new InstructionBuilder();
-
- if (actions.getPacketHandling() instanceof Deny) {
- InstructionUtils.createDropInstructions(ib);
- } else if (actions.getPacketHandling() instanceof Permit) {
- //Permit actPermit = (Permit) actions.getPacketHandling();
- } else {
- InstructionUtils.createDropInstructions(ib);
- }
-
- ib.setOrder(0);
- ib.setKey(new InstructionKey(0));
- // Instructions List Stores Individual Instructions
- List<Instruction> instructions = Lists.newArrayList();
- instructions.add(ib.build());
-
- // Call the InstructionBuilder Methods Containing Actions
- ib = this.getMutablePipelineInstructionBuilder();
- ib.setOrder(1);
- ib.setKey(new InstructionKey(1));
- instructions.add(ib.build());
-
- // Add InstructionBuilder to the Instruction(s)Builder List
- InstructionsBuilder isb = new InstructionsBuilder();
- isb.setInstruction(instructions);
- return isb;
- }
-
- private MatchBuilder buildMatch(String ruleName, Matches matches, String dpId) {
- MatchBuilder matchBuilder = new MatchBuilder();
-
- if (matches.getAceType() instanceof AceIp) {
- AceIp aceIp = (AceIp)matches.getAceType();
- if (aceIp.getAceIpVersion() instanceof AceIpv4) {
- AceIpv4 aceIpv4 = (AceIpv4) aceIp.getAceIpVersion();
- MatchUtils.createSrcL3IPv4Match(matchBuilder, aceIpv4.getSourceIpv4Address());
- MatchUtils.createDstL3IPv4Match(matchBuilder, aceIpv4.getDestinationIpv4Address());
- MatchUtils.createIpProtocolMatch(matchBuilder, aceIp.getIpProtocol());
- MatchUtils.addLayer4Match(matchBuilder, aceIp.getIpProtocol().intValue(),
- aceIp.getSourcePortRange().getLowerPort().getValue().intValue(),
- aceIp.getDestinationPortRange().getLowerPort().getValue().intValue());
- }
- } else if (matches.getAceType() instanceof AceEth) {
- AceEth aceEth = (AceEth) matches.getAceType();
- MatchUtils.createEthSrcMatch(matchBuilder, new MacAddress(aceEth.getSourceMacAddress().getValue()));
- MatchUtils.createDestEthMatch(matchBuilder, new MacAddress(aceEth.getDestinationMacAddress().getValue()),
- new MacAddress(aceEth.getDestinationMacAddressMask().getValue()));
- }
-
- //MatchUtils.createInPortMatch(matchBuilder, Long.getLong(dpId), Long.getLong(matches.getInputInterface()));
- return matchBuilder;
- }
-
- @Override
- public void removeClassifierRules(Sff sff, AccessList acl) {
- // TODO Auto-generated method stub
-
- }
-
-
- protected void writeFlow(FlowBuilder flowBuilder, NodeBuilder nodeBuilder) {
- LOG.debug("writeFlow: flowBuilder: {}, nodeBuilder: {}",
- flowBuilder.build(), nodeBuilder.build());
- dbutils.merge(LogicalDatastoreType.CONFIGURATION, createNodePath(nodeBuilder), nodeBuilder.build());
- dbutils.put(LogicalDatastoreType.CONFIGURATION, createFlowPath(flowBuilder, nodeBuilder), flowBuilder.build());
- }
-
- protected void removeFlow(FlowBuilder flowBuilder, NodeBuilder nodeBuilder) {
- dbutils.delete(LogicalDatastoreType.CONFIGURATION, createFlowPath(flowBuilder, nodeBuilder));
- }
-
- private String getDpid(Node node) {
- long dpid = southbound.getDataPathId(node);
- if (dpid == 0) {
- LOG.warn("getDpid: DPID could not be found for node: {}", node.getNodeId().getValue());
- }
- return String.valueOf(dpid);
- }
-
- private static InstanceIdentifier<Flow> createFlowPath(FlowBuilder flowBuilder, NodeBuilder nodeBuilder) {
- return InstanceIdentifier.builder(Nodes.class)
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class,
- nodeBuilder.getKey())
- .augmentation(FlowCapableNode.class)
- .child(Table.class, new TableKey(flowBuilder.getTableId()))
- .child(Flow.class, flowBuilder.getKey()).build();
- }
-
- private static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node>
- createNodePath(NodeBuilder nodeBuilder) {
- return InstanceIdentifier.builder(Nodes.class)
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class,
- nodeBuilder.getKey()).build();
- }
-
- private short getTable() {
- return Service.INGRESS_ACL.getTable();
- }
-
- private final InstructionBuilder getMutablePipelineInstructionBuilder() {
- Service nextService = orchestrator.getNextServiceInPipeline(Service.INGRESS_ACL);
- if (nextService != null) {
- return InstructionUtils.createGotoTableInstructions(new InstructionBuilder(), nextService.getTable());
- } else {
- return InstructionUtils.createDropInstructions(new InstructionBuilder());
- }
- }
-
- private void setDependencies(ServiceReference serviceReference) {
- nodeCacheManager = (NodeCacheManager) ServiceHelper.getGlobalInstance(NodeCacheManager.class, this);
- southbound = (Southbound) ServiceHelper.getGlobalInstance(Southbound.class, this);
- orchestrator = (PipelineOrchestrator) ServiceHelper.getGlobalInstance(PipelineOrchestrator.class, this);
- }
-}
--- /dev/null
+/*
+ * Copyright (c) 2015 Dell, 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.ovsdb.openstack.netvirt.sfc.standalone.openflow13;
+
+import com.google.common.base.Preconditions;
+
+import com.google.common.collect.Iterables;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.ovsdb.openstack.netvirt.api.NodeCacheManager;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.INetvirtSfcOF13Provider;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.ISfcClassifierService;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.NshUtils;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
+import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
+import org.opendaylight.sfc.provider.api.SfcProviderRenderedPathAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServicePathAPI;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.RspName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathInput;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.RenderedServicePaths;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.path.first.hop.info.RenderedServicePathFirstHop;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePathKey;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.rendered.service.path.RenderedServicePathHop;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPaths;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.Acl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.Ace;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.Matches;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIp;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.acl.rev150105.RedirectToSfc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.Classifiers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.Classifier;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.Bridges;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.bridges.Bridge;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.Sff;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Open vSwitch OpenFlow 1.3 Networking Provider for Netvirt SFC
+ * @author Arun Yerra
+ */
+public class NetvirtSfcStandaloneOF13Provider implements INetvirtSfcOF13Provider {
+ private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcStandaloneOF13Provider.class);
+ private static final short TABLE_0_CLASSIFIER = 0;
+ private static final short TABLE_3_INGR_ACL = 50;
+
+ private volatile NodeCacheManager nodeCacheManager;
+ private volatile Southbound southbound;
+ private MdsalUtils mdsalUtils;
+ private SfcClassifier sfcClassifier;
+
+ // TBD:: Remove these constants after integrating with openstack.
+ private static final String TUNNEL_DST = "192.168.50.75";
+ private static final String TUNNEL_VNID = "10";
+ private static final String CLIENT_PORT_NAME = "vethl-h35_2";
+ private static final String SERVER_PORT_NAME = "vethl-h35_4";
+ private static final String CLIENT_GPE_PORT_NAME = "sw1-vxlangpe-0";
+ private static final String SERVER_GPE_PORT_NAME = "sw6-vxlangpe-0";
+ private static final String INTERFACE_TYPE_VXLAN_GPE = "vxlangpe";
+
+ /**
+ * {@link NetvirtSfcStandaloneOF13Provider} constructor.
+ * @param dataBroker MdSal {@link DataBroker}
+ */
+ public NetvirtSfcStandaloneOF13Provider(final DataBroker dataBroker) {
+ Preconditions.checkNotNull(dataBroker, "Input dataBroker cannot be NULL!");
+ mdsalUtils = new MdsalUtils(dataBroker);
+ //this.setDependencies(null);
+ sfcClassifier = new SfcClassifier(dataBroker, southbound, mdsalUtils);
+ }
+
+ public void removeClassifierRules(Sff sff, Acl acl) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void addClassifierRules(Acl acl) {
+ String aclName = acl.getAclName();
+ Classifiers classifiers = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, getClassifierIid());
+ if (classifiers == null) {
+ LOG.debug("add: No Classifiers found");
+ return;
+ }
+
+ LOG.debug("add: Classifiers: {}", classifiers);
+ for (Classifier classifier : classifiers.getClassifier()) {
+ if (classifier.getAcl().equals(aclName)) {
+ if (classifier.getBridges() != null) {
+ addClassifierRules(classifier.getBridges(), acl);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void removeClassifierRules(Acl acl) {
+ String aclName = acl.getAclName();
+ Classifiers classifiers = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, getClassifierIid());
+ if (classifiers != null) {
+ for (Classifier classifier : classifiers.getClassifier()) {
+ if (classifier.getAcl().equalsIgnoreCase(aclName)) {
+ if (classifier.getSffs() != null) {
+ for (Sff sff : classifier.getSffs().getSff()) {
+ removeClassifierRules(sff, acl);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void setSfcClassifierService(ISfcClassifierService sfcClassifierService) {
+
+ }
+
+ @Override
+ public void addClassifierRules(Bridge bridge, Acl acl) {
+
+ }
+
+ @Override
+ public void addClassifierRules(Bridges bridges, Acl acl) {
+ Preconditions.checkNotNull(bridges, "Input bridges cannot be NULL!");
+ Preconditions.checkNotNull(acl, "Input accesslist cannot be NULL!");
+
+ for (Ace ace : acl.getAccessListEntries().getAce()) {
+ processAclEntry(ace, bridges, true);
+ }
+ }
+
+ private void processAclEntry(Ace entry, Bridges bridges, boolean write) {
+ Matches matches = entry.getMatches();
+ if (matches == null) {
+ LOG.warn("processAclEntry: matches not found");
+ return;
+ }
+
+ RenderedServicePath rsp = getRenderedServicePath(entry);
+ if (rsp == null) {
+ LOG.warn("Failed to get renderedServicePatch for entry: {}", entry);
+ return;
+ }
+
+ LOG.info("processAclEntry: RSP: {}", rsp);
+ List<RenderedServicePathHop> pathHopList = rsp.getRenderedServicePathHop();
+ if (pathHopList.isEmpty()) {
+ LOG.warn("Service Path = {} has empty hops!!", rsp.getName());
+ return;
+ }
+
+ for (Bridge bridge : bridges.getBridge()) {
+ if (bridge.getDirection().getIntValue() == 0) {
+ Node bridgeNode = getBridgeNode(bridge.getName());
+ if (bridgeNode == null) {
+ LOG.debug("processAclEntry: bridge {} not yet configured. Skip processing !!", bridge.getName());
+ continue;
+ }
+
+ long tunnelOfPort = southbound.getOFPort(bridgeNode, CLIENT_GPE_PORT_NAME);
+ if (tunnelOfPort == 0L) {
+ LOG.error("programAclEntry: Could not identify tunnel port {} -> OF ({}) on {}",
+ CLIENT_GPE_PORT_NAME, tunnelOfPort, bridgeNode);
+ return;
+ }
+
+ long localOfPort = southbound.getOFPort(bridgeNode, CLIENT_PORT_NAME);
+ if (localOfPort == 0L) {
+ LOG.error("programAclEntry: Could not identify local port {} -> OF ({}) on {}",
+ CLIENT_GPE_PORT_NAME, localOfPort, bridgeNode);
+ return;
+ }
+
+ // Find the first Hop within an RSP.
+ // The classifier flow needs to send all matched traffic to this first hop SFF.
+ RenderedServicePathFirstHop firstRspHop = SfcProviderRenderedPathAPI
+ .readRenderedServicePathFirstHop(new RspName(rsp.getName()));
+
+ LOG.debug("First Hop IPAddress = {}, Port = {}", firstRspHop.getIp().getIpv4Address().getValue(),
+ firstRspHop.getPort().getValue());
+
+ NshUtils nshHeader = new NshUtils();
+ // C1 is the normal overlay dest ip and c2 is the vnid
+ // Hardcoded for now, netvirt integration will have those values
+ nshHeader.setNshMetaC1(NshUtils.convertIpAddressToLong(new Ipv4Address(TUNNEL_DST)));
+ nshHeader.setNshMetaC2(Long.parseLong(TUNNEL_VNID));
+ nshHeader.setNshNsp(rsp.getPathId());
+
+ RenderedServicePathHop firstHop = pathHopList.get(0);
+ nshHeader.setNshNsi(firstHop.getServiceIndex());
+ nshHeader.setNshTunIpDst(firstRspHop.getIp().getIpv4Address());
+ nshHeader.setNshTunUdpPort(firstRspHop.getPort());
+ LOG.debug("The Nsh Header = {}", nshHeader);
+
+ handleLocalInPort(southbound.getDataPathId(bridgeNode), rsp.getPathId().toString(), localOfPort,
+ TABLE_0_CLASSIFIER, TABLE_3_INGR_ACL, matches, true);
+
+ handleSfcClassiferFlows(southbound.getDataPathId(bridgeNode), TABLE_3_INGR_ACL, entry.getRuleName(),
+ matches, nshHeader, tunnelOfPort, true);
+ } else {
+ Node bridgeNode = getBridgeNode(bridge.getName());
+ if (bridgeNode == null) {
+ LOG.debug("processAclEntry: bridge {} not yet configured. Skip processing !!", bridge.getName());
+ continue;
+ }
+
+ long tunnelOfPort = southbound.getOFPort(bridgeNode, SERVER_GPE_PORT_NAME);
+ if (tunnelOfPort == 0L) {
+ LOG.error("programAclEntry: Could not identify tunnel port {} -> OF ({}) on {}",
+ CLIENT_GPE_PORT_NAME, tunnelOfPort, bridgeNode);
+ return;
+ }
+
+ long localOfPort = southbound.getOFPort(bridgeNode, SERVER_PORT_NAME);
+ if (localOfPort == 0L) {
+ LOG.error("programAclEntry: Could not identify local port {} -> OF ({}) on {}",
+ CLIENT_GPE_PORT_NAME, localOfPort, bridgeNode);
+ return;
+ }
+
+ RenderedServicePathHop lastRspHop = Iterables.getLast(rsp.getRenderedServicePathHop());
+
+ LOG.debug("programAclEntry: Last Hop #: {}, nsi: {}", lastRspHop.getHopNumber().intValue(),
+ lastRspHop.getServiceIndex().intValue() - 1);
+
+ NshUtils nshHeader = new NshUtils();
+ nshHeader.setNshNsp(rsp.getPathId());
+ nshHeader.setNshNsi((short)(lastRspHop.getServiceIndex().intValue() - 1));
+ nshHeader.setNshMetaC2(Long.parseLong(TUNNEL_VNID));
+ LOG.debug("programAclEntry: The Nsh Header = {}", nshHeader);
+
+ //handleLocalEgressPort(southbound.getDataPathId(bridgeNode), rsp.getPathId().toString(), localOfPort,
+ // TABLE_0_CLASSIFIER, TABLE_3_INGR_ACL, true);
+
+ handleEgressSfcClassiferFlows(southbound.getDataPathId(bridgeNode),
+ TABLE_0_CLASSIFIER, entry.getRuleName(), matches, nshHeader, tunnelOfPort, localOfPort, true);
+ }
+ }
+ }
+
+ private RenderedServicePath getRenderedServicePath (Ace entry) {
+ RenderedServicePath rsp = null;
+ RedirectToSfc sfcRedirect = entry.getActions().getAugmentation(RedirectToSfc.class);
+ LOG.debug("Processing ACL entry = {} sfcRedirect = {}", entry.getRuleName(), sfcRedirect);
+ if (sfcRedirect == null) {
+ LOG.warn("processAClEntry: sfcRedirect is null");
+ return null;
+ }
+
+ if (sfcRedirect.getRspName() != null) {
+ rsp = getRenderedServicePathFromRsp(sfcRedirect.getRspName());
+ } else if (sfcRedirect.getSfpName() != null) {
+ LOG.warn("getRenderedServicePath: sfp not handled yet");
+ } else {
+ rsp = getRenderedServicePathFromSfc(entry);
+ }
+ LOG.info("getRenderedServicePath: rsp: {}", rsp);
+ return rsp;
+ }
+
+ private RenderedServicePath getRenderedServicePathFromRsp(String rspName) {
+ return null;//getRsp(rspName);
+ }
+
+ private RenderedServicePath getRenderedServicePathFromSfc (Ace entry) {
+ RedirectToSfc sfcRedirect = entry.getActions().getAugmentation(RedirectToSfc.class);
+ LOG.debug("Processing ACL entry = {} sfcRedirect = {}", entry.getRuleName(), sfcRedirect);
+ if (sfcRedirect == null) {
+ LOG.warn("processAClEntry: sfcRedirect is null");
+ return null;
+ }
+
+ String sfcName = sfcRedirect.getSfcName();
+ ServiceFunctionPath sfp = getSfp(sfcName);
+ if (sfp == null || sfp.getName() == null) {
+ LOG.warn("There is no configured SFP with sfcName = {}; so skip installing the ACL entry!!", sfcName);
+ return null;
+ }
+
+ LOG.debug("Processing Redirect to SFC = {}, SFP = {}", sfcName, sfp);
+ // If RSP doesn't exist, create an RSP.
+ String sfpName = sfp.getName().getValue();
+ RenderedServicePath rsp = getRspforSfp(sfpName);
+ String rspName = sfp.getName().getValue() + "_rsp";
+ if (rsp == null) {
+ LOG.info("No configured RSP corresponding to SFP = {}, Creating new RSP = {}", sfpName, rspName);
+ CreateRenderedPathInput rspInput = new CreateRenderedPathInputBuilder()
+ .setParentServiceFunctionPath(sfpName)
+ .setName(rspName)
+ .setSymmetric(sfp.isSymmetric())
+ .build();
+ rsp = SfcProviderRenderedPathAPI.createRenderedServicePathAndState(sfp, rspInput);
+ if (rsp == null) {
+ LOG.warn("failed to add RSP");
+ return null;
+ }
+
+ // If SFP is symmetric, create RSP in the reverse direction.
+ if (sfp.isSymmetric()) {
+ LOG.info("SFP = {} is symmetric, installing RSP in the reverse direction!!", sfpName);
+ String rspNameRev = rspName + "-Reverse";
+ RenderedServicePath rspReverse = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL,
+ getRspId(rspNameRev));
+ if (rspReverse == null) {
+ rspReverse = SfcProviderRenderedPathAPI.createSymmetricRenderedServicePathAndState(rsp);
+ if (rspReverse == null) {
+ LOG.warn("failed to add reverse RSP");
+ return null;
+ }
+ }
+ }
+ }
+ return rsp;
+ }
+
+ private void handleLocalEgressPort(long dataPathId, String s, long localOfPort, short writeTable,
+ short gotoTable, boolean write) {
+
+ }
+
+ private void handleEgressSfcClassiferFlows(long dataPathId, short writeTable, String ruleName,
+ Matches matches, NshUtils nshHeader, long tunnelOfPort,
+ long outOfPort, boolean write) {
+ sfcClassifier.programEgressSfcClassiferFlows(dataPathId, writeTable, ruleName, matches, nshHeader,
+ tunnelOfPort, outOfPort, write);
+ }
+
+ private void handleSfcClassiferFlows(long dataPathId, short writeTable, String ruleName,
+ Matches matches, NshUtils nshHeader, long tunnelOfPort,
+ boolean write) {
+ sfcClassifier.programSfcClassiferFlows(dataPathId, writeTable, ruleName, matches, nshHeader,
+ tunnelOfPort, write);
+ }
+
+ private InstanceIdentifier<RenderedServicePaths> getRspsId() {
+ return InstanceIdentifier.builder(RenderedServicePaths.class).build();
+ }
+
+ private InstanceIdentifier<RenderedServicePath> getRspId(String rspName) {
+ return InstanceIdentifier.builder(RenderedServicePaths.class)
+ .child(RenderedServicePath.class, new RenderedServicePathKey(new RspName(rspName))).build();
+ }
+
+ public Node getBridgeNode(String bridgeName) {
+ Node nodeFound = null;
+ final List<Node> nodes = nodeCacheManager.getBridgeNodes();
+ if (nodes != null && !nodes.isEmpty()) {
+ for (Node node : nodes) {
+ if (southbound.getBridge(node, bridgeName) != null) {
+ nodeFound = node;
+ break;
+ }
+ }
+ }
+ return nodeFound;
+ }
+
+ public RenderedServicePath getRspforSfp(String sfpName) {
+ RenderedServicePath rspFound = null;
+ RenderedServicePaths rsps = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, this.getRspsId());
+ if (rsps != null) {
+ for (RenderedServicePath rsp : rsps.getRenderedServicePath()) {
+ if (rsp.getParentServiceFunctionPath() != null) {
+ if (rsp.getParentServiceFunctionPath().getValue().equals(sfpName)) {
+ rspFound = rsp;
+ }
+ }
+ }
+ }
+ return rspFound;
+ }
+
+ public ServiceFunctionPath getSfp(String redirectSfc) {
+ ServiceFunctionPath sfpFound = null;
+ ServiceFunctionPaths sfps = SfcProviderServicePathAPI.readAllServiceFunctionPaths();
+ if (sfps != null) {
+ for (ServiceFunctionPath sfp: sfps.getServiceFunctionPath()) {
+ if (sfp.getServiceChainName().getValue().equalsIgnoreCase(redirectSfc)) {
+ sfpFound = sfp;
+ }
+ }
+ }
+ return sfpFound;
+ }
+
+/*
+ * (TABLE:0) EGRESS VM TRAFFIC TOWARDS TEP
+ * MATCH: DESTINATION ETHERNET ADDR AND OPENFLOW INPORT
+ * INSTRUCTION: SET TUNNELID AND GOTO TABLE TUNNEL TABLE (N)
+ * TABLE=0,IN_PORT=2,DL_SRC=00:00:00:00:00:01 \
+ * ACTIONS=SET_FIELD:5->TUN_ID,GOTO_TABLE=1"
+ */
+ public String getDestIp(Matches match) {
+ if (match.getAceType() instanceof AceIp) {
+ AceIp aceIp = (AceIp)match.getAceType();
+ if (aceIp.getAceIpVersion() instanceof AceIpv4) {
+ AceIpv4 aceIpv4 = (AceIpv4) aceIp.getAceIpVersion();
+ if (aceIpv4.getDestinationIpv4Network() != null) {
+ String ipAddrPrefix = aceIpv4.getDestinationIpv4Network().getValue();
+ return new StringTokenizer(ipAddrPrefix, "/").nextToken();
+ }
+ }
+ }
+ return null;
+ }
+
+ public String getSourceIp(Matches match) {
+ if (match.getAceType() instanceof AceIp) {
+ AceIp aceIp = (AceIp)match.getAceType();
+ if (aceIp.getAceIpVersion() instanceof AceIpv4) {
+ AceIpv4 aceIpv4 = (AceIpv4) aceIp.getAceIpVersion();
+ if (aceIpv4.getSourceIpv4Network() != null) {
+ //String ipAddr = new StringTokenizer(ipAddrPrefix, "/").nextToken();
+ return aceIpv4.getSourceIpv4Network().getValue();
+ }
+ }
+ }
+ return null;
+ }
+
+ private InstanceIdentifier<Classifiers> getClassifierIid() {
+ return InstanceIdentifier.create(Classifiers.class);
+ }
+
+ public void handleLocalInPort(long dpidLong, String segmentationId, Long inPort,
+ short writeTable, short goToTableId, Matches matches, boolean write) {
+ sfcClassifier.programLocalInPort(dpidLong, segmentationId, inPort, writeTable, goToTableId, matches, write);
+ }
+
+ @Override
+ public void setDependencies(ServiceReference serviceReference) {
+ nodeCacheManager = (NodeCacheManager) ServiceHelper.getGlobalInstance(NodeCacheManager.class, this);
+ southbound = (Southbound) ServiceHelper.getGlobalInstance(Southbound.class, this);
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2015 Red Hat, 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.ovsdb.openstack.netvirt.sfc.standalone.openflow13;
+
+import com.google.common.collect.Lists;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.NshUtils;
+import org.opendaylight.ovsdb.utils.mdsal.openflow.ActionUtils;
+import org.opendaylight.ovsdb.utils.mdsal.openflow.FlowUtils;
+import org.opendaylight.ovsdb.utils.mdsal.openflow.InstructionUtils;
+import org.opendaylight.ovsdb.utils.mdsal.openflow.MatchUtils;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.Matches;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.matches.ace.type.AceEth;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIp;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg0;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxRegCaseBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SfcClassifier {
+ private static final Logger LOG = LoggerFactory.getLogger(SfcClassifier.class);
+ private DataBroker dataBroker;
+ private Southbound southbound;
+ private MdsalUtils mdsalUtils;
+ public final static long REG_VALUE_FROM_LOCAL = 0x1L;
+ public final static long REG_VALUE_FROM_REMOTE = 0x2L;
+ public static final Class<? extends NxmNxReg> REG_FIELD = NxmNxReg0.class;
+ private static final String OPENFLOW = "openflow:";
+
+ public SfcClassifier(DataBroker dataBroker, Southbound southbound, MdsalUtils mdsalUtils) {
+ this.dataBroker = dataBroker;
+ this.southbound = southbound;
+ this.mdsalUtils = mdsalUtils;
+ }
+
+ /*
+ * (TABLE:50) EGRESS VM TRAFFIC TOWARDS TEP with NSH header
+ * MATCH: Match fields passed through ACL entry
+ * INSTRUCTION: SET TUNNELID AND GOTO TABLE TUNNEL TABLE (N)
+ * TABLE=0,IN_PORT=2,DL_SRC=00:00:00:00:00:01 \
+ * ACTIONS=SET_FIELD:5->TUN_ID,GOTO_TABLE=1"
+ */
+ public void programSfcClassiferFlows(Long dpidLong, short writeTable, String ruleName, Matches match,
+ NshUtils nshHeader, long tunnelOfPort, boolean write) {
+ String nodeName = OPENFLOW + dpidLong;
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(nodeName);
+ FlowBuilder flowBuilder = new FlowBuilder();
+
+ MatchBuilder matchBuilder = buildMatch(match);
+ flowBuilder.setMatch(matchBuilder.build());
+
+ String flowId = "sfcClass_" + ruleName + "_" + nshHeader.getNshNsp();
+ flowBuilder.setId(new FlowId(flowId));
+ FlowKey key = new FlowKey(new FlowId(flowId));
+ flowBuilder.setBarrier(true);
+ flowBuilder.setTableId(writeTable);
+ flowBuilder.setKey(key);
+ flowBuilder.setFlowName(flowId);
+ flowBuilder.setHardTimeout(0);
+ flowBuilder.setIdleTimeout(0);
+
+ if (write) {
+ List<Action> actionList = getNshAction(nshHeader);
+ ActionBuilder ab = new ActionBuilder();
+
+ ab.setAction(ActionUtils.outputAction(FlowUtils.getNodeConnectorId(tunnelOfPort, nodeName)));
+ ab.setOrder(actionList.size());
+ ab.setKey(new ActionKey(actionList.size()));
+ actionList.add(ab.build());
+
+ ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ aab.setAction(actionList);
+
+ InstructionBuilder ib = new InstructionBuilder();
+ ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+ ib.setOrder(0);
+ ib.setKey(new InstructionKey(0));
+ List<Instruction> instructions = Lists.newArrayList();
+ instructions.add(ib.build());
+
+ InstructionsBuilder isb = new InstructionsBuilder();
+ isb.setInstruction(instructions);
+ flowBuilder.setInstructions(isb.build());
+ writeFlow(flowBuilder, nodeBuilder);
+ } else {
+ removeFlow(flowBuilder, nodeBuilder);
+ }
+ }
+
+ public void programEgressSfcClassiferFlows(Long dpidLong, short writeTable, String ruleName,
+ Matches match, NshUtils nshHeader,
+ long tunnelOfPort, long outOfPort, boolean write) {
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dpidLong);
+ FlowBuilder flowBuilder = new FlowBuilder();
+
+ MatchBuilder matchBuilder = new MatchBuilder();
+ flowBuilder.setMatch(MatchUtils.createInPortMatch(matchBuilder, dpidLong, tunnelOfPort).build());
+ flowBuilder.setMatch(
+ MatchUtils.createTunnelIDMatch(matchBuilder, BigInteger.valueOf(nshHeader.getNshMetaC2())).build());
+ flowBuilder.setMatch(MatchUtils.addNxNspMatch(matchBuilder, nshHeader.getNshNsp()).build());
+ flowBuilder.setMatch(MatchUtils.addNxNsiMatch(matchBuilder, nshHeader.getNshNsi()).build());
+
+ String flowId = "egressSfcClass_" + ruleName + "_" + nshHeader.getNshNsp() + "_" + nshHeader.getNshNsi();
+ flowBuilder.setId(new FlowId(flowId));
+ FlowKey key = new FlowKey(new FlowId(flowId));
+ flowBuilder.setBarrier(true);
+ flowBuilder.setTableId(writeTable);
+ flowBuilder.setKey(key);
+ flowBuilder.setFlowName(flowId);
+ flowBuilder.setHardTimeout(0);
+ flowBuilder.setIdleTimeout(0);
+
+ if (write) {
+ List<Action> actionList = new ArrayList<>();
+ ActionBuilder ab = new ActionBuilder();
+
+ ab.setAction(ActionUtils.nxLoadRegAction(new DstNxRegCaseBuilder().setNxReg(REG_FIELD).build(),
+ BigInteger.valueOf(REG_VALUE_FROM_REMOTE)));
+ ab.setOrder(0);
+ ab.setKey(new ActionKey(0));
+ actionList.add(ab.build());
+
+ ab.setAction(ActionUtils.outputAction(FlowUtils.getNodeConnectorId(dpidLong, outOfPort)));
+ ab.setOrder(1);
+ ab.setKey(new ActionKey(1));
+ actionList.add(ab.build());
+
+ ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ aab.setAction(actionList);
+
+ InstructionBuilder ib = new InstructionBuilder();
+ ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+ ib.setOrder(0);
+ ib.setKey(new InstructionKey(0));
+ List<Instruction> instructions = new ArrayList<>();
+ instructions.add(ib.build());
+
+ InstructionsBuilder isb = new InstructionsBuilder();
+ isb.setInstruction(instructions);
+
+ flowBuilder.setInstructions(isb.build());
+ writeFlow(flowBuilder, nodeBuilder);
+ } else {
+ removeFlow(flowBuilder, nodeBuilder);
+ }
+ }
+
+ private List<Action> getNshAction(NshUtils header) {
+ // Build the Actions to Add the NSH Header
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nshC1Load =
+ ActionUtils.nxLoadNshc1RegAction(header.getNshMetaC1());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nshC2Load =
+ ActionUtils.nxLoadNshc2RegAction(header.getNshMetaC2());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nspLoad =
+ ActionUtils.nxSetNspAction(header.getNshNsp());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nsiLoad =
+ ActionUtils.nxSetNsiAction(header.getNshNsi());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action loadChainTunVnid =
+ ActionUtils.nxLoadTunIdAction(BigInteger.valueOf(header.getNshNsp()), false);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action loadChainTunDest =
+ ActionUtils.nxLoadTunIPv4Action(header.getNshTunIpDst().getValue(), false);
+
+ int count = 0;
+ List<Action> actionList = Lists.newArrayList();
+ actionList.add(new ActionBuilder().setOrder(count++).setAction(nshC1Load).build());
+ actionList.add(new ActionBuilder().setOrder(count++).setAction(nshC2Load).build());
+ actionList.add(new ActionBuilder().setOrder(count++).setAction(nspLoad).build());
+ actionList.add(new ActionBuilder().setOrder(count++).setAction(nsiLoad).build());
+ actionList.add(new ActionBuilder().setOrder(count++).setAction(loadChainTunDest).build());
+ actionList.add(new ActionBuilder().setOrder(count++).setAction(loadChainTunVnid).build());
+ return actionList;
+ }
+
+ public void programLocalInPort(Long dpidLong, String segmentationId, Long inPort,
+ short writeTable, short goToTableId, Matches match, boolean write) {
+ String nodeName = OPENFLOW + dpidLong;
+
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(nodeName);
+ FlowBuilder flowBuilder = new FlowBuilder();
+
+ MatchBuilder matchBuilder = buildMatch(match);
+ flowBuilder.setMatch(matchBuilder.build());
+ flowBuilder.setMatch(MatchUtils.createInPortMatch(matchBuilder, dpidLong, inPort).build());
+ String flowId = "sfcIngress_" + segmentationId + "_" + inPort;
+ flowBuilder.setId(new FlowId(flowId));
+ FlowKey key = new FlowKey(new FlowId(flowId));
+ flowBuilder.setStrict(true);
+ flowBuilder.setBarrier(false);
+ flowBuilder.setTableId(writeTable);
+ flowBuilder.setKey(key);
+ flowBuilder.setFlowName(flowId);
+ flowBuilder.setHardTimeout(0);
+ flowBuilder.setIdleTimeout(0);
+
+ if (write) {
+ InstructionBuilder ib = new InstructionBuilder();
+ InstructionsBuilder isb = new InstructionsBuilder();
+ List<Instruction> instructions = Lists.newArrayList();
+
+ InstructionUtils.createSetTunnelIdInstructions(ib, new BigInteger(segmentationId));
+ ApplyActionsCase aac = (ApplyActionsCase) ib.getInstruction();
+ List<Action> actionList = aac.getApplyActions().getAction();
+
+ // TODO: Mark the packets as sfc classified?
+
+ ActionBuilder ab = new ActionBuilder();
+ ab.setAction(ActionUtils.nxLoadRegAction(new DstNxRegCaseBuilder().setNxReg(REG_FIELD).build(),
+ BigInteger.valueOf(REG_VALUE_FROM_LOCAL)));
+ ab.setOrder(1);
+ ab.setKey(new ActionKey(1));
+ actionList.add(ab.build());
+
+ ib.setOrder(0);
+ ib.setKey(new InstructionKey(0));
+ instructions.add(ib.build());
+
+ // Next service GOTO Instructions Need to be appended to the List
+ ib = InstructionUtils.createGotoTableInstructions(new InstructionBuilder(), goToTableId);
+ ib.setOrder(1);
+ ib.setKey(new InstructionKey(1));
+ instructions.add(ib.build());
+
+ isb.setInstruction(instructions);
+ flowBuilder.setInstructions(isb.build());
+ writeFlow(flowBuilder, nodeBuilder);
+ } else {
+ removeFlow(flowBuilder, nodeBuilder);
+ }
+ }
+
+ public MatchBuilder buildMatch(Matches matches) {
+ MatchBuilder matchBuilder = new MatchBuilder();
+
+ if (matches.getAceType() instanceof AceIp) {
+ AceIp aceIp = (AceIp)matches.getAceType();
+ if (aceIp.getAceIpVersion() instanceof AceIpv4) {
+ //AceIpv4 aceIpv4 = (AceIpv4) aceIp.getAceIpVersion();
+ //MatchUtils.createSrcL3IPv4Match(matchBuilder, aceIpv4.getSourceIpv4Network());
+ //MatchUtils.createDstL3IPv4Match(matchBuilder, aceIpv4.getDestinationIpv4Network());
+ MatchUtils.createIpProtocolMatch(matchBuilder, aceIp.getProtocol());
+ MatchUtils.addLayer4Match(matchBuilder, aceIp.getProtocol().intValue(), 0,
+ aceIp.getDestinationPortRange().getLowerPort().getValue().intValue());
+ }
+ } else if (matches.getAceType() instanceof AceEth) {
+ AceEth aceEth = (AceEth) matches.getAceType();
+ MatchUtils.createEthSrcMatch(matchBuilder, new MacAddress(aceEth.getSourceMacAddress().getValue()));
+ MatchUtils.createDestEthMatch(matchBuilder, new MacAddress(aceEth.getDestinationMacAddress().getValue()),
+ new MacAddress(aceEth.getDestinationMacAddressMask().getValue()));
+ }
+
+ LOG.info("buildMatch: {}", matchBuilder.build());
+ return matchBuilder;
+ }
+
+ protected void writeFlow(FlowBuilder flowBuilder, NodeBuilder nodeBuilder) {
+ LOG.debug("writeFlow: flowBuilder: {}, nodeBuilder: {}", flowBuilder.build(), nodeBuilder.build());
+ mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, FlowUtils.createNodePath(nodeBuilder),
+ nodeBuilder.build());
+ mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, FlowUtils.createFlowPath(flowBuilder, nodeBuilder),
+ flowBuilder.build());
+ }
+
+ protected void removeFlow(FlowBuilder flowBuilder, NodeBuilder nodeBuilder) {
+ mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, FlowUtils.createFlowPath(flowBuilder, nodeBuilder));
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2015 Red Hat, 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.ovsdb.openstack.netvirt.sfc.standalone.openflow13.services;
+
+import org.opendaylight.ovsdb.openstack.netvirt.providers.ConfigInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.AbstractServiceInstance;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.ISfcClassifierService;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.NshUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.Matches;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SfcClassifierService extends AbstractServiceInstance implements ConfigInterface, ISfcClassifierService {
+ private static final Logger LOG = LoggerFactory.getLogger(SfcClassifierService.class);
+
+ public SfcClassifierService(Service service) {
+ super(service);
+ }
+
+ public SfcClassifierService() {
+ super(Service.SFC_CLASSIFIER);
+ }
+
+ @Override
+ public void setDependencies(BundleContext bundleContext, ServiceReference serviceReference) {
+ super.setDependencies(bundleContext.getServiceReference(SfcClassifierService.class.getName()), this);
+ }
+
+ @Override
+ public void setDependencies(Object impl) {}
+
+ @Override
+ public void programIngressClassifier(long dataPathId, String ruleName, Matches matches, NshUtils nshHeader, long vxGpeOfPort, boolean write) {
+
+ }
+
+ @Override
+ public void programSfcTable(long dataPathId, long vxGpeOfPort, short goToTableId, boolean write) {
+
+ }
+
+ @Override
+ public void programEgressClassifier1(long dataPathId, long vxGpeOfPort, long nsp, short nsi, int tunnelOfPort, int tunnelId, short gotoTableId, boolean write) {
+
+ }
+
+ @Override
+ public void programEgressClassifier(long dataPathId, long vxGpeOfPort, long nsp, short nsi, long sfOfPort, int tunnelId, boolean write) {
+
+ }
+
+ @Override
+ public void programEgressClassifierBypass(long dataPathId, long vxGpeOfPort, long nsp, short nsi, long sfOfPort, int tunnelId, boolean write) {
+
+ }
+
+ @Override
+ public void program_sfEgress(long dataPathId, int dstPort, boolean write) {
+
+ }
+
+ @Override
+ public void program_sfIngress(long dataPathId, int dstPort, long sfOfPort, String ipAddress, String sfDplName, boolean write) {
+
+ }
+
+ @Override
+ public void programStaticArpEntry(long dataPathId, long ofPort, String macAddressStr, String ipAddress, boolean write) {
+
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2015 Red Hat, 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.ovsdb.openstack.netvirt.sfc.workaround;
+
+import com.google.common.base.Preconditions;
+import java.util.List;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
+import org.opendaylight.ovsdb.openstack.netvirt.api.NodeCacheManager;
+import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbTables;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.INetvirtSfcOF13Provider;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.ISfcClassifierService;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.NshUtils;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.SfcUtils;
+import org.opendaylight.ovsdb.southbound.SouthboundConstants;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
+import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
+import org.opendaylight.sfc.provider.api.SfcProviderRenderedPathAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceForwarderAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceFunctionAPI;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.data.plane.locator.locator.type.Ip;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathInput;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.path.first.hop.info.RenderedServicePathFirstHop;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.rendered.service.path.RenderedServicePathHop;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.Acl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.Ace;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.Matches;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.acl.rev150105.RedirectToSfc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.Classifiers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.Classifier;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.Bridges;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.bridges.Bridge;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.Sff;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Options;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NetvirtSfcWorkaroundOF13Provider implements INetvirtSfcOF13Provider {
+ private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcWorkaroundOF13Provider.class);
+ private volatile NodeCacheManager nodeCacheManager;
+ private volatile Southbound southbound;
+ private volatile ISfcClassifierService sfcClassifierService;
+ private static final short SFC_TABLE = 150;
+ private static final int GPE_PORT = 6633;
+ private static final String NETWORK_TYPE_VXLAN = "vxlan";
+ private MdsalUtils mdsalUtils;
+ private SfcUtils sfcUtils;
+ private static final String VXGPE = "vxgpe";
+ private static final String TUNNEL_DST = "192.168.120.31";
+ private static final String TUNNEL_VNID = "10";
+ public static final String TUNNEL_ENDPOINT_KEY = "local_ip";
+
+ public NetvirtSfcWorkaroundOF13Provider(final DataBroker dataBroker, MdsalUtils mdsalUtils, SfcUtils sfcUtils) {
+ Preconditions.checkNotNull(dataBroker, "Input dataBroker cannot be NULL!");
+ Preconditions.checkNotNull(mdsalUtils, "Input mdsalUtils cannot be NULL!");
+ Preconditions.checkNotNull(sfcUtils, "Input sfcUtils cannot be NULL!");
+
+ this.mdsalUtils = mdsalUtils;
+ this.sfcUtils = sfcUtils;
+ //this.setDependencies(null);
+ }
+
+ public void setSfcClassifierService(ISfcClassifierService sfcClassifierService) {
+ this.sfcClassifierService = sfcClassifierService;
+ }
+
+ @Override
+ public void addClassifierRules(Bridge bridge, Acl acl) {
+
+ }
+
+ @Override
+ public void addClassifierRules(Bridges bridges, Acl acl) {
+ Preconditions.checkNotNull(bridges, "Input bridges cannot be NULL!");
+ Preconditions.checkNotNull(acl, "Input acl cannot be NULL!");
+ }
+
+ @Override
+ public void removeClassifierRules(Sff sff, Acl acl) {
+
+ }
+
+ @Override
+ public void addClassifierRules(Acl acl) {
+ String aclName = acl.getAclName();
+ Classifiers classifiers = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, sfcUtils.getClassifierIid());
+ if (classifiers == null) {
+ LOG.debug("addClassifierRules: No Classifiers found");
+ return;
+ }
+
+ LOG.debug("addClassifierRules: Classifiers: {}", classifiers);
+ for (Classifier classifier : classifiers.getClassifier()) {
+ if (classifier.getAcl().equals(aclName)) {
+ for (Ace ace : acl.getAccessListEntries().getAce()) {
+ processAclEntry(ace);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void removeClassifierRules(Acl acl) {
+
+ }
+
+ private void processAclEntry(Ace entry) {
+ Matches matches = entry.getMatches();
+ Preconditions.checkNotNull(matches, "Input bridges cannot be NULL!");
+
+ RenderedServicePath rsp = getRenderedServicePath(entry);
+ if (rsp == null) {
+ LOG.warn("Failed to get renderedServicePatch for entry: {}", entry);
+ return;
+ }
+
+ handleRenderedServicePath(rsp, entry);
+ }
+
+ private void handleRenderedServicePathOld(RenderedServicePath rsp, Ace entry) {
+ LOG.info("handleRenderedServicePath: RSP: {}", rsp);
+
+ Matches matches = entry.getMatches();
+ if (matches == null) {
+ LOG.warn("processAclEntry: matches not found");
+ return;
+ }
+
+ List<RenderedServicePathHop> pathHopList = rsp.getRenderedServicePathHop();
+ if (pathHopList.isEmpty()) {
+ LOG.warn("handleRenderedServicePath: RSP {} has empty hops!!", rsp.getName());
+ return;
+ }
+ LOG.info("handleRenderedServicePath: pathHopList: {}", pathHopList);
+
+ final List<Node> bridgeNodes = nodeCacheManager.getBridgeNodes();
+ if (bridgeNodes == null || bridgeNodes.isEmpty()) {
+ LOG.warn("handleRenderedServicePath: There are no bridges to process");
+ return;
+ }
+ for (Node bridgeNode : bridgeNodes) {
+ OvsdbBridgeAugmentation ovsdbBridgeAugmentation = southbound.getBridge(bridgeNode, "br-int");
+ if (ovsdbBridgeAugmentation == null) {
+ continue;
+ }
+ long vxGpeOfPort = getOFPort(bridgeNode, VXGPE);
+ if (vxGpeOfPort == 0L) {
+ LOG.warn("programAclEntry: Could not identify tunnel port {} -> OF ({}) on {}",
+ VXGPE, vxGpeOfPort, bridgeNode);
+ continue;
+ }
+ long dataPathId = southbound.getDataPathId(bridgeNode);
+ if (dataPathId == 0L) {
+ LOG.warn("programAclEntry: Could not identify datapathId on {}", bridgeNode);
+ continue;
+ }
+
+ // Find the first Hop within an RSP.
+ // The classifier flow needs to send all matched traffic to this first hop SFF.
+ RenderedServicePathFirstHop firstRspHop = SfcProviderRenderedPathAPI
+ .readRenderedServicePathFirstHop(rsp.getName());
+
+ LOG.info("handleRenderedServicePath: firstRspHop: {}", firstRspHop);
+ LOG.debug("handleRenderedServicePath: First Hop IPAddress = {}, Port = {}",
+ firstRspHop.getIp().getIpv4Address().getValue(),
+ firstRspHop.getPort().getValue());
+
+ NshUtils nshHeader = new NshUtils();
+ nshHeader.setNshMetaC1(NshUtils.convertIpAddressToLong(new Ipv4Address(TUNNEL_DST)));
+ nshHeader.setNshMetaC2(Long.parseLong(TUNNEL_VNID)); // get from register //get from
+ nshHeader.setNshNsp(rsp.getPathId());
+
+ RenderedServicePathHop firstHop = pathHopList.get(0);
+ RenderedServicePathHop lastHop = pathHopList.get(pathHopList.size()-1);
+ ServiceFunction serviceFunction =
+ SfcProviderServiceFunctionAPI.readServiceFunction(
+ SfName.getDefaultInstance(firstHop.getServiceFunctionName().getValue()));
+ if (serviceFunction == null) {
+ LOG.warn("programAclEntry: Could not identify ServiceFunction {} on {}",
+ firstHop.getServiceFunctionName().getValue(), bridgeNode);
+ continue;
+ }
+
+ nshHeader.setNshNsi(firstHop.getServiceIndex());
+ // workaround: bypass sff and got directly to sf
+ //nshHeader.setNshTunIpDst(firstRspHop.getIp().getIpv4Address());
+ IpAddress sfIpAddress = sfcUtils.getSfIpAddress(serviceFunction);
+ String sfDplName = sfcUtils.getSfDplName(serviceFunction);
+ //sfcUtils.getSfIp(firstHop.getServiceFunctionName().getValue());
+ nshHeader.setNshTunIpDst(sfIpAddress.getIpv4Address());
+ nshHeader.setNshTunUdpPort(firstRspHop.getPort());
+ LOG.debug("handleRenderedServicePath: NSH Header = {}", nshHeader);
+
+ sfcClassifierService.programIngressClassifier(dataPathId, entry.getRuleName(), matches,
+ nshHeader, vxGpeOfPort, true);
+
+ sfcClassifierService.program_sfEgress(dataPathId, GPE_PORT, true);
+ long sfOfPort = getSfPort(bridgeNode, sfDplName);
+
+ String sfMac = getMacFromExternalIds(bridgeNode, sfDplName);
+ String sfIpString = new String(sfIpAddress.getValue());
+ LOG.info("handleRenderedServicePath: sfDplName: {}, sfMac: {}, sfOfPort: {}, sfIpAddress: {}",
+ sfDplName, sfMac, sfOfPort, sfIpString);
+ if (sfMac != null) { // install if the sf is on this bridge, expand when using multiple bridges
+ sfcClassifierService.program_sfIngress(dataPathId, GPE_PORT, sfOfPort, sfIpString, sfDplName, true);
+ sfcClassifierService.programStaticArpEntry(dataPathId, 0L, sfMac, sfIpString, true);
+ }
+
+ short lastServiceindex = (short)((lastHop.getServiceIndex()).intValue() - 1);
+ sfcClassifierService.programEgressClassifier(dataPathId, vxGpeOfPort, rsp.getPathId(),
+ lastServiceindex, sfOfPort, 0, true);
+ sfcClassifierService.programEgressClassifierBypass(dataPathId, vxGpeOfPort, rsp.getPathId(),
+ lastServiceindex, sfOfPort, 0, true);
+
+ sfcClassifierService.programSfcTable(dataPathId, vxGpeOfPort, SFC_TABLE, true);
+ }
+ }
+
+ private void handleRenderedServicePath(RenderedServicePath rsp, Ace entry) {
+ LOG.info("handleRenderedServicePath: RSP: {}", rsp);
+
+ Matches matches = entry.getMatches();
+ if (matches == null) {
+ LOG.warn("processAclEntry: matches not found");
+ return;
+ }
+
+ List<RenderedServicePathHop> pathHopList = rsp.getRenderedServicePathHop();
+ if (pathHopList.isEmpty()) {
+ LOG.warn("handleRenderedServicePath: RSP {} has empty hops!!", rsp.getName());
+ return;
+ }
+ LOG.info("handleRenderedServicePath: pathHopList: {}", pathHopList);
+
+ RenderedServicePathFirstHop firstRspHop = SfcProviderRenderedPathAPI
+ .readRenderedServicePathFirstHop(rsp.getName());
+ LOG.info("handleRenderedServicePath: firstRspHop: {}", firstRspHop);
+
+ RenderedServicePathHop firstHop = pathHopList.get(0);
+ RenderedServicePathHop lastHop = pathHopList.get(pathHopList.size()-1);
+
+ final List<Node> bridgeNodes = nodeCacheManager.getBridgeNodes();
+ if (bridgeNodes == null || bridgeNodes.isEmpty()) {
+ LOG.warn("handleRenderedServicePath: There are no bridges to process");
+ return;
+ }
+ for (RenderedServicePathHop hop : pathHopList) {
+ for (Node bridgeNode : bridgeNodes) {
+ // ignore bridges other than br-int
+ OvsdbBridgeAugmentation ovsdbBridgeAugmentation = southbound.getBridge(bridgeNode, "br-int");
+ if (ovsdbBridgeAugmentation == null) {
+ continue;
+ }
+ long vxGpeOfPort = getOFPort(bridgeNode, VXGPE);
+ if (vxGpeOfPort == 0L) {
+ LOG.warn("programAclEntry: Could not identify gpe vtep {} -> OF ({}) on {}",
+ VXGPE, vxGpeOfPort, bridgeNode);
+ continue;
+ }
+ long dataPathId = southbound.getDataPathId(bridgeNode);
+ if (dataPathId == 0L) {
+ LOG.warn("programAclEntry: Could not identify datapathId on {}", bridgeNode);
+ continue;
+ }
+
+ ServiceFunction serviceFunction =
+ SfcProviderServiceFunctionAPI.readServiceFunction(firstHop.getServiceFunctionName());
+ if (serviceFunction == null) {
+ LOG.warn("programAclEntry: Could not identify ServiceFunction {} on {}",
+ firstHop.getServiceFunctionName().getValue(), bridgeNode);
+ continue;
+ }
+ ServiceFunctionForwarder serviceFunctionForwarder =
+ SfcProviderServiceForwarderAPI
+ .readServiceFunctionForwarder(hop.getServiceFunctionForwarder());
+ if (serviceFunctionForwarder == null) {
+ LOG.warn("programAclEntry: Could not identify ServiceFunctionForwarder {} on {}",
+ firstHop.getServiceFunctionName().getValue(), bridgeNode);
+ continue;
+ }
+
+ handleSf(bridgeNode, serviceFunction);
+ handleSff(bridgeNode, serviceFunctionForwarder, serviceFunction, hop, firstHop, lastHop,
+ entry.getRuleName(), matches, vxGpeOfPort, rsp);
+ if (firstHop == lastHop) {
+ handleSff(bridgeNode, serviceFunctionForwarder, serviceFunction, hop, null, lastHop,
+ entry.getRuleName(), matches, vxGpeOfPort, rsp);
+ }
+ }
+ }
+ }
+
+ private void handleSff(Node bridgeNode, ServiceFunctionForwarder serviceFunctionForwarder,
+ ServiceFunction serviceFunction,
+ RenderedServicePathHop hop,
+ RenderedServicePathHop firstHop,
+ RenderedServicePathHop lastHop,
+ String ruleName, Matches matches,
+ long vxGpeOfPort, RenderedServicePath rsp) {
+ long dataPathId = southbound.getDataPathId(bridgeNode);
+
+ if (hop == firstHop) {
+ LOG.info("handleSff: first hop processing {} - {}",
+ bridgeNode.getNodeId(), serviceFunctionForwarder.getName());
+ NshUtils nshHeader = new NshUtils();
+ nshHeader.setNshNsp(rsp.getPathId());
+ nshHeader.setNshNsi(firstHop.getServiceIndex());
+ if (isSffOnBridge(bridgeNode, serviceFunctionForwarder)) {
+ LOG.info("handleSff: sff and bridge are the same: {} - {}, skipping first sff",
+ bridgeNode.getNodeId(), serviceFunctionForwarder.getName());
+ Ip ip = sfcUtils.getSfIp(serviceFunction);
+ nshHeader.setNshTunIpDst(ip.getIp().getIpv4Address());
+ nshHeader.setNshTunUdpPort(ip.getPort());
+ } else {
+ LOG.info("handleSff: sff and bridge are not the same: {} - {}, sending to first sff",
+ bridgeNode.getNodeId(), serviceFunctionForwarder.getName());
+ Ip ip = sfcUtils.getSffIp(serviceFunctionForwarder);
+ nshHeader.setNshTunIpDst(ip.getIp().getIpv4Address());
+ nshHeader.setNshTunUdpPort(ip.getPort());
+ }
+ sfcClassifierService.programIngressClassifier(dataPathId, ruleName, matches,
+ nshHeader, vxGpeOfPort, true);
+ } else if (hop == lastHop) {
+ LOG.info("handleSff: last hop processing {} - {}",
+ bridgeNode.getNodeId(), serviceFunctionForwarder.getName());
+ short lastServiceindex = (short)((lastHop.getServiceIndex()).intValue() - 1);
+ String sfDplName = sfcUtils.getSfDplName(serviceFunction);
+ long sfOfPort = getSfPort(bridgeNode, sfDplName);
+ sfcClassifierService.programEgressClassifier(dataPathId, vxGpeOfPort, rsp.getPathId(),
+ lastServiceindex, sfOfPort, 0, true);
+ sfcClassifierService.programEgressClassifierBypass(dataPathId, vxGpeOfPort, rsp.getPathId(),
+ lastServiceindex, sfOfPort, 0, true);
+ } else {
+ // add typical sff flows
+ }
+
+ sfcClassifierService.programSfcTable(dataPathId, vxGpeOfPort, SFC_TABLE, true);
+ }
+
+ void handleSf(Node bridgeNode, ServiceFunction serviceFunction) {
+ if (isSfOnBridge(bridgeNode, serviceFunction)) {
+ LOG.info("handleSf: sf and bridge are on the same node: {} - {}, adding workaround and arp",
+ bridgeNode.getNodeId(), serviceFunction.getName());
+ long dataPathId = southbound.getDataPathId(bridgeNode);
+ Ip ip = sfcUtils.getSfIp(serviceFunction);
+ String sfIpAddr = String.valueOf(ip.getIp().getValue());
+ int sfIpPort = ip.getPort().getValue(); //GPE_PORT
+ String sfDplName = sfcUtils.getSfDplName(serviceFunction);
+ long sfOfPort = getSfPort(bridgeNode, sfDplName);
+ String sfMac = getMacFromExternalIds(bridgeNode, sfDplName);
+ if (sfMac == null) {
+ LOG.warn("handleSff: could not find mac for {} on {}", sfDplName, bridgeNode);
+ return;
+ }
+ //should be sffdplport, but they should all be the same 6633/4790
+ sfcClassifierService.program_sfEgress(dataPathId, sfIpPort, true);
+ sfcClassifierService.program_sfIngress(dataPathId, sfIpPort, sfOfPort, sfIpAddr, sfDplName, true);
+ sfcClassifierService.programStaticArpEntry(dataPathId, 0L, sfMac, sfIpAddr, true);
+ }
+ }
+
+ private boolean isSffOnBridge(Node bridgeNode, ServiceFunctionForwarder serviceFunctionForwarder) {
+ String local_ip = "";
+ Ip ip = sfcUtils.getSffIp(serviceFunctionForwarder);
+ Node ovsdbNode = southbound.readOvsdbNode(bridgeNode);
+ if (ovsdbNode != null) {
+ OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
+ if (ovsdbNodeAugmentation != null && ovsdbNodeAugmentation.getOpenvswitchOtherConfigs() != null) {
+ southbound.getOtherConfig(ovsdbNode, OvsdbTables.OPENVSWITCH, TUNNEL_ENDPOINT_KEY);
+ }
+
+ }
+ return local_ip.equals(String.valueOf(ip.getIp().getValue()));
+ }
+
+ private boolean isSfOnBridge(Node bridgeNode, ServiceFunction serviceFunction) {
+ String sfDplName = sfcUtils.getSfDplName(serviceFunction);
+ long sfOfPort = getSfPort(bridgeNode, sfDplName);
+ return sfOfPort != 0L;
+ }
+
+ private RenderedServicePath getRenderedServicePath (Ace entry) {
+ RenderedServicePath rsp = null;
+ RedirectToSfc sfcRedirect = entry.getActions().getAugmentation(RedirectToSfc.class);
+ LOG.debug("Processing ACL entry = {} sfcRedirect = {}", entry.getRuleName(), sfcRedirect);
+ if (sfcRedirect == null) {
+ LOG.warn("processAClEntry: sfcRedirect is null");
+ return null;
+ }
+
+ if (sfcRedirect.getRspName() != null) {
+ rsp = getRenderedServicePathFromRsp(sfcRedirect.getRspName());
+ } else if (sfcRedirect.getSfpName() != null) {
+ LOG.warn("getRenderedServicePath: sfp not handled yet");
+ } else {
+ rsp = getRenderedServicePathFromSfc(entry);
+ }
+ LOG.info("getRenderedServicePath: rsp: {}", rsp);
+ return rsp;
+ }
+
+ private RenderedServicePath getRenderedServicePathFromRsp(String rspName) {
+ return sfcUtils.getRsp(rspName);
+ }
+
+ private RenderedServicePath getRenderedServicePathFromSfc (Ace entry) {
+ RedirectToSfc sfcRedirect = entry.getActions().getAugmentation(RedirectToSfc.class);
+ LOG.debug("Processing ACL entry = {} sfcRedirect = {}", entry.getRuleName(), sfcRedirect);
+ if (sfcRedirect == null) {
+ LOG.warn("processAClEntry: sfcRedirect is null");
+ return null;
+ }
+
+ String sfcName = sfcRedirect.getSfcName();
+ ServiceFunctionPath sfp = sfcUtils.getSfp(sfcName);
+ if (sfp == null || sfp.getName() == null) {
+ LOG.warn("There is no configured SFP with sfcName = {}; so skip installing the ACL entry!!", sfcName);
+ return null;
+ }
+
+ LOG.debug("Processing Redirect to SFC = {}, SFP = {}", sfcName, sfp);
+ // If RSP doesn't exist, create an RSP.
+ String sfpName = sfp.getName().getValue();
+ RenderedServicePath rsp = sfcUtils.getRspforSfp(sfpName);
+ String rspName = sfp.getName().getValue() + "_rsp";
+ if (rsp == null) {
+ LOG.info("No configured RSP corresponding to SFP = {}, Creating new RSP = {}", sfpName, rspName);
+ CreateRenderedPathInput rspInput = new CreateRenderedPathInputBuilder()
+ .setParentServiceFunctionPath(sfpName)
+ .setName(rspName)
+ .setSymmetric(sfp.isSymmetric())
+ .build();
+ rsp = SfcProviderRenderedPathAPI.createRenderedServicePathAndState(sfp, rspInput);
+ if (rsp == null) {
+ LOG.warn("failed to add RSP");
+ return null;
+ }
+
+ // If SFP is symmetric, create RSP in the reverse direction.
+ if (sfp.isSymmetric()) {
+ LOG.info("SFP = {} is symmetric, installing RSP in the reverse direction!!", sfpName);
+ String rspNameRev = rspName + "-Reverse";
+ RenderedServicePath rspReverse = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL,
+ sfcUtils.getRspId(rspNameRev));
+ if (rspReverse == null) {
+ rspReverse = SfcProviderRenderedPathAPI.createSymmetricRenderedServicePathAndState(rsp);
+ if (rspReverse == null) {
+ LOG.warn("failed to add reverse RSP");
+ return null;
+ }
+ }
+ }
+ }
+ return rsp;
+ }
+
+ // loop through all ports looking for vxlan types, skip vxgpe, keep the rest
+ // first pass we only have two tunnels: one for normal vxlan and the other for gpe
+ // so just return the first non-gpe vxlan port
+ private long getTunnelOfPort(Node bridgeNode, String vxGpePortName) {
+ long port = 0L;
+ List<OvsdbTerminationPointAugmentation> ovsdbTerminationPointAugmentations =
+ southbound.getTerminationPointsOfBridge(bridgeNode);
+ if (!ovsdbTerminationPointAugmentations.isEmpty()) {
+ for (OvsdbTerminationPointAugmentation terminationPointAugmentation :
+ ovsdbTerminationPointAugmentations) {
+ if (terminationPointAugmentation.getInterfaceType() ==
+ SouthboundConstants.OVSDB_INTERFACE_TYPE_MAP.get(NETWORK_TYPE_VXLAN)) {
+ if (!terminationPointAugmentation.getName().equals(vxGpePortName)) {
+ port = terminationPointAugmentation.getOfport();
+ break;
+ }
+ }
+ }
+ }
+ return port;
+ }
+
+ private long getSfPort(Node bridgeNode, String sfPortName) {
+ long port = 0L;
+ port = getOFPort(bridgeNode, sfPortName);
+ return port;
+ }
+
+ private long getOFPort(Node bridgeNode, String portName) {
+ long ofPort = 0L;
+ OvsdbTerminationPointAugmentation port =
+ southbound.extractTerminationPointAugmentation(bridgeNode, portName);
+ if (port != null) {
+ ofPort = southbound.getOFPort(port);
+ }
+ if (ofPort == 0L) {
+ for (int i = 0; i < 5; i++) {
+ LOG.info("Looking for ofPort {}, try: {}", portName, i);
+ if (ofPort == 0L) {
+ TerminationPoint tp = southbound.readTerminationPoint(bridgeNode, null, portName);
+ if (tp != null) {
+ port = tp.getAugmentation(OvsdbTerminationPointAugmentation.class);
+ if (port != null) {
+ ofPort = southbound.getOFPort(port);
+ break;
+ }
+ }
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ return ofPort;
+ }
+
+ private String getMacFromOptions(Node bridgeNode, String portName) {
+ String mac = null;
+ OvsdbTerminationPointAugmentation port = southbound.extractTerminationPointAugmentation(bridgeNode, portName);
+ LOG.info("getMac: portName: {}, bridgeNode: {},,, port: {}", portName, bridgeNode, port);
+ if (port != null && port.getOptions() != null) {
+ //mac = southbound.getOptionsValue(port.getOptions(), EXTERNAL_ID_VM_MAC);
+ for (Options option : port.getOptions()) {
+ LOG.info("getMac: option: {}", option);
+ if (option.getOption().equals(Constants.EXTERNAL_ID_VM_MAC)) {
+ mac = option.getValue();
+ break;
+ }
+ }
+ }
+ return mac;
+ }
+
+ private String getMacFromExternalIds(Node bridgeNode, String portName) {
+ String mac = null;
+ OvsdbTerminationPointAugmentation port = southbound.getTerminationPointOfBridge(bridgeNode, portName);
+ LOG.info("getMac: portName: {}, bridgeNode: {},,, port: {}", portName, bridgeNode, port);
+ if (port != null && port.getInterfaceExternalIds() != null) {
+ mac = southbound.getInterfaceExternalIdsValue(port, Constants.EXTERNAL_ID_VM_MAC);
+ }
+ return mac;
+ }
+
+ @Override
+ public void setDependencies(ServiceReference serviceReference) {
+ nodeCacheManager = (NodeCacheManager) ServiceHelper.getGlobalInstance(NodeCacheManager.class, this);
+ southbound = (Southbound) ServiceHelper.getGlobalInstance(Southbound.class, this);
+ sfcClassifierService =
+ (ISfcClassifierService) ServiceHelper.getGlobalInstance(ISfcClassifierService.class, this);
+ LOG.info("sfcClassifierService= {}", sfcClassifierService);
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2015 Red Hat, 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.ovsdb.openstack.netvirt.sfc.workaround.services;
+
+import com.google.common.collect.Lists;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.ConfigInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.AbstractServiceInstance;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.ISfcClassifierService;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.NshUtils;
+import org.opendaylight.ovsdb.utils.mdsal.openflow.ActionUtils;
+import org.opendaylight.ovsdb.utils.mdsal.openflow.FlowUtils;
+import org.opendaylight.ovsdb.utils.mdsal.openflow.InstructionUtils;
+import org.opendaylight.ovsdb.utils.mdsal.openflow.MatchUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.Matches;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.matches.ace.type.AceEth;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIp;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxRegCaseBuilder;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SfcClassifierService extends AbstractServiceInstance implements ConfigInterface, ISfcClassifierService {
+ private static final Logger LOG = LoggerFactory.getLogger(SfcClassifierService.class);
+ private static final short TABLE_0 = 0;
+ private static final short UDP_SHORT = 17;
+ static int cookieIndex = 0;
+
+ private enum FlowID {
+ FLOW_INGRESSCLASS(1), FLOW_SFINGRESS(2), FLOW_SFEGRESS(3), FLOW_SFARP(4),
+ FLOW_EGRESSCLASSUNUSED(5), FLOW_EGRESSCLASS(6), FLOW_EGRESSCLASSBYPASS(7), FLOW_SFCTABLE(8);
+
+ private int value;
+ FlowID(int value) {
+ this.value = value;
+ }
+
+ }
+
+ //private AtomicLong flowCookieInc = new AtomicLong(0x1L);
+ private BigInteger getCookie(FlowID flowID) {
+ String cookieString = new String().format("1110%02d%010d", flowID.value, cookieIndex++);
+ //new String().format("1100%02d00%04d", flowID.value, flowCookieInc.getAndIncrement());
+ // "1100%02000000d%04d"
+ return new BigInteger(cookieString, 16);
+ }
+
+ public SfcClassifierService(Service service) {
+ super(service);
+ }
+
+ public SfcClassifierService() {
+ super(Service.SFC_CLASSIFIER);
+ }
+
+ @Override
+ public void setDependencies(BundleContext bundleContext, ServiceReference serviceReference) {
+ super.setDependencies(bundleContext.getServiceReference(ISfcClassifierService.class.getName()), this);
+ }
+
+ @Override
+ public void setDependencies(Object impl) {}
+
+ @Override
+ public void programIngressClassifier(long dataPathId, String ruleName, Matches matches,
+ NshUtils nshHeader, long vxGpeOfPort, boolean write) {
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dataPathId);
+ FlowBuilder flowBuilder = new FlowBuilder();
+
+ MatchBuilder matchBuilder = buildMatch(matches);
+ MatchUtils.addNxRegMatch(matchBuilder,
+ MatchUtils.RegMatch.of(FlowUtils.REG_FIELD, FlowUtils.REG_VALUE_FROM_LOCAL));
+ MatchUtils.addNxRegMatch(matchBuilder,
+ MatchUtils.RegMatch.of(FlowUtils.REG_FIELD, FlowUtils.REG_VALUE_FROM_LOCAL));
+ flowBuilder.setMatch(matchBuilder.build());
+
+ String flowId = "sfcIngressClass_" + ruleName;// + "_" + nshHeader.getNshNsp();
+ flowBuilder.setId(new FlowId(flowId));
+ FlowKey key = new FlowKey(new FlowId(flowId));
+ flowBuilder.setBarrier(true);
+ flowBuilder.setTableId(getTable());
+ flowBuilder.setKey(key);
+ flowBuilder.setFlowName(flowId);
+ flowBuilder.setHardTimeout(0);
+ flowBuilder.setIdleTimeout(0);
+ flowBuilder.setCookie(new FlowCookie(getCookie(FlowID.FLOW_INGRESSCLASS)));
+
+ if (write) {
+ ActionBuilder ab = new ActionBuilder();
+ List<Action> actionList = new ArrayList<>();
+
+ ab.setAction(ActionUtils.nxMoveTunIdtoNshc2());
+ ab.setOrder(actionList.size());
+ ab.setKey(new ActionKey(actionList.size()));
+ actionList.add(ab.build());
+
+ getNshAction(nshHeader, actionList);
+
+ ab.setAction(ActionUtils.outputAction(FlowUtils.getNodeConnectorId(dataPathId, vxGpeOfPort)));
+ ab.setOrder(actionList.size());
+ ab.setKey(new ActionKey(actionList.size()));
+ actionList.add(ab.build());
+
+ ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ aab.setAction(actionList);
+
+ InstructionBuilder ib = new InstructionBuilder();
+ ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+ ib.setOrder(0);
+ ib.setKey(new InstructionKey(0));
+ List<Instruction> instructions = Lists.newArrayList();
+ instructions.add(ib.build());
+
+ InstructionsBuilder isb = new InstructionsBuilder();
+ isb.setInstruction(instructions);
+ flowBuilder.setInstructions(isb.build());
+ writeFlow(flowBuilder, nodeBuilder);
+ } else {
+ removeFlow(flowBuilder, nodeBuilder);
+ }
+ }
+
+ @Override
+ public void programSfcTable(long dataPathId, long vxGpeOfPort, short goToTableId, boolean write) {
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dataPathId);
+ FlowBuilder flowBuilder = new FlowBuilder();
+
+ MatchBuilder matchBuilder = new MatchBuilder();
+ MatchUtils.createInPortMatch(matchBuilder, dataPathId, vxGpeOfPort);
+ flowBuilder.setMatch(matchBuilder.build());
+
+ String flowId = "sfcTable_" + vxGpeOfPort;
+ flowBuilder.setId(new FlowId(flowId));
+ FlowKey key = new FlowKey(new FlowId(flowId));
+ flowBuilder.setBarrier(true);
+ flowBuilder.setTableId(TABLE_0);
+ flowBuilder.setKey(key);
+ flowBuilder.setFlowName(flowId);
+ flowBuilder.setHardTimeout(0);
+ flowBuilder.setIdleTimeout(0);
+ flowBuilder.setPriority(1000);
+ flowBuilder.setCookie(new FlowCookie(getCookie(FlowID.FLOW_SFCTABLE)));
+ flowBuilder.setCookieMask(new FlowCookie(getCookie(FlowID.FLOW_SFCTABLE)));
+
+ if (write) {
+ InstructionsBuilder isb = new InstructionsBuilder();
+ List<Instruction> instructions = Lists.newArrayList();
+ InstructionBuilder ib =
+ InstructionUtils.createGotoTableInstructions(new InstructionBuilder(), goToTableId);
+ ib.setOrder(0);
+ ib.setKey(new InstructionKey(0));
+ instructions.add(ib.build());
+
+ isb.setInstruction(instructions);
+ flowBuilder.setInstructions(isb.build());
+ writeFlow(flowBuilder, nodeBuilder);
+ } else {
+ removeFlow(flowBuilder, nodeBuilder);
+ }
+ }
+
+ @Override
+ public void programEgressClassifier1(long dataPathId, long vxGpeOfPort, long nsp, short nsi,
+ int tunnelOfPort, int tunnelId, short gotoTableId, boolean write) {
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dataPathId);
+ FlowBuilder flowBuilder = new FlowBuilder();
+
+ MatchBuilder matchBuilder = new MatchBuilder();
+ MatchUtils.createInPortMatch(matchBuilder, dataPathId, vxGpeOfPort);
+ MatchUtils.addNxNspMatch(matchBuilder, nsp);
+ MatchUtils.addNxNsiMatch(matchBuilder, nsi);
+ flowBuilder.setMatch(matchBuilder.build());
+
+ String flowId = "sfcEgressClass1_" + vxGpeOfPort;
+ flowBuilder.setId(new FlowId(flowId));
+ FlowKey key = new FlowKey(new FlowId(flowId));
+ flowBuilder.setBarrier(true);
+ flowBuilder.setTableId(TABLE_0);
+ flowBuilder.setKey(key);
+ flowBuilder.setFlowName(flowId);
+ flowBuilder.setHardTimeout(0);
+ flowBuilder.setIdleTimeout(0);
+ flowBuilder.setCookie(new FlowCookie(getCookie(FlowID.FLOW_EGRESSCLASSUNUSED)));
+ flowBuilder.setCookieMask(new FlowCookie(getCookie(FlowID.FLOW_EGRESSCLASSUNUSED)));
+
+ if (write) {
+ InstructionsBuilder isb = new InstructionsBuilder();
+ List<Instruction> instructions = Lists.newArrayList();
+ InstructionBuilder ib = new InstructionBuilder();
+
+ /*List<Action> actionList = Lists.newArrayList();
+
+ ActionBuilder ab = new ActionBuilder();
+ ab.setAction(ActionUtils.nxMoveNshc2ToTunId());
+ ab.setOrder(0);
+ ab.setKey(new ActionKey(0));
+ actionList.add(ab.build());
+
+ ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ aab.setAction(actionList);
+ ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+ ib.setOrder(instructions.size());
+ ib.setKey(new InstructionKey(instructions.size()));
+ instructions.add(ib.build());*/
+
+ ib = InstructionUtils.createGotoTableInstructions(new InstructionBuilder(), getTable());
+ ib.setOrder(instructions.size());
+ ib.setKey(new InstructionKey(instructions.size()));
+ instructions.add(ib.build());
+
+ isb.setInstruction(instructions);
+ flowBuilder.setInstructions(isb.build());
+ writeFlow(flowBuilder, nodeBuilder);
+ } else {
+ removeFlow(flowBuilder, nodeBuilder);
+ }
+ }
+
+ @Override
+ public void programEgressClassifier(long dataPathId, long vxGpeOfPort, long nsp, short nsi,
+ long sfOfPort, int tunnelId, boolean write) {
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dataPathId);
+ FlowBuilder flowBuilder = new FlowBuilder();
+
+ MatchBuilder matchBuilder = new MatchBuilder();
+ MatchUtils.createInPortMatch(matchBuilder, dataPathId, vxGpeOfPort);
+ MatchUtils.addNxNspMatch(matchBuilder, nsp);
+ MatchUtils.addNxNsiMatch(matchBuilder, nsi);
+ flowBuilder.setMatch(matchBuilder.build());
+
+ String flowId = "sfcEgressClass_" + nsp + "_" + + nsi + "_" + vxGpeOfPort;
+ flowBuilder.setId(new FlowId(flowId));
+ FlowKey key = new FlowKey(new FlowId(flowId));
+ flowBuilder.setBarrier(true);
+ flowBuilder.setTableId(TABLE_0);
+ flowBuilder.setKey(key);
+ flowBuilder.setFlowName(flowId);
+ flowBuilder.setHardTimeout(0);
+ flowBuilder.setIdleTimeout(0);
+ flowBuilder.setCookie(new FlowCookie(getCookie(FlowID.FLOW_EGRESSCLASS)));
+ flowBuilder.setCookieMask(new FlowCookie(getCookie(FlowID.FLOW_EGRESSCLASS)));
+
+ if (write) {
+ InstructionsBuilder isb = new InstructionsBuilder();
+ List<Instruction> instructions = Lists.newArrayList();
+ List<Action> actionList = Lists.newArrayList();
+
+ ActionBuilder ab = new ActionBuilder();
+
+ ab.setAction(
+ ActionUtils.nxLoadRegAction(new DstNxRegCaseBuilder().setNxReg(FlowUtils.REG_FIELD).build(),
+ BigInteger.valueOf(FlowUtils.REG_VALUE_FROM_LOCAL)));
+ ab.setOrder(actionList.size());
+ ab.setKey(new ActionKey(actionList.size()));
+ actionList.add(ab.build());
+
+ ab.setAction(ActionUtils.nxMoveNshc2ToTunId());
+ ab.setOrder(actionList.size());
+ ab.setKey(new ActionKey(actionList.size()));
+ actionList.add(ab.build());
+
+ ab.setAction(ActionUtils.nxResubmitAction((int)sfOfPort, TABLE_0));
+ ab.setOrder(actionList.size());
+ ab.setKey(new ActionKey(actionList.size()));
+ actionList.add(ab.build());
+
+ ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ aab.setAction(actionList);
+ InstructionBuilder ib = new InstructionBuilder();
+ ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+ ib.setOrder(0);
+ ib.setKey(new InstructionKey(0));
+ instructions.add(ib.build());
+
+ isb.setInstruction(instructions);
+ flowBuilder.setInstructions(isb.build());
+ writeFlow(flowBuilder, nodeBuilder);
+ } else {
+ removeFlow(flowBuilder, nodeBuilder);
+ }
+ }
+
+ @Override
+ public void programEgressClassifierBypass(long dataPathId, long vxGpeOfPort, long nsp, short nsi,
+ long sfOfPort, int tunnelId, boolean write) {
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dataPathId);
+ FlowBuilder flowBuilder = new FlowBuilder();
+
+ MatchBuilder matchBuilder = new MatchBuilder();
+ MatchUtils.createInPortMatch(matchBuilder, dataPathId, sfOfPort);
+ MatchUtils.addNxRegMatch(matchBuilder,
+ MatchUtils.RegMatch.of(FlowUtils.REG_FIELD, FlowUtils.REG_VALUE_FROM_LOCAL));
+ MatchUtils.addNxNspMatch(matchBuilder, nsp);
+ MatchUtils.addNxNsiMatch(matchBuilder, nsi);
+ flowBuilder.setMatch(matchBuilder.build());
+
+ String flowId = "sfcEgressClassBypass_" + nsp + "_" + + nsi + "_" + sfOfPort;
+ flowBuilder.setId(new FlowId(flowId));
+ FlowKey key = new FlowKey(new FlowId(flowId));
+ flowBuilder.setBarrier(true);
+ flowBuilder.setTableId(TABLE_0);
+ flowBuilder.setKey(key);
+ flowBuilder.setFlowName(flowId);
+ flowBuilder.setHardTimeout(0);
+ flowBuilder.setIdleTimeout(0);
+ flowBuilder.setCookie(new FlowCookie(getCookie(FlowID.FLOW_EGRESSCLASSBYPASS)));
+ flowBuilder.setCookieMask(new FlowCookie(getCookie(FlowID.FLOW_EGRESSCLASSBYPASS)));
+ flowBuilder.setPriority(40000); //Needs to be above default priority of 32768
+
+ if (write) {
+ InstructionsBuilder isb = new InstructionsBuilder();
+ List<Instruction> instructions = Lists.newArrayList();
+
+ InstructionBuilder ib;
+ ib = this.getMutablePipelineInstructionBuilder();
+ ib.setOrder(0);
+ ib.setKey(new InstructionKey(0));
+ instructions.add(ib.build());
+
+ isb.setInstruction(instructions);
+ flowBuilder.setInstructions(isb.build());
+ writeFlow(flowBuilder, nodeBuilder);
+ } else {
+ removeFlow(flowBuilder, nodeBuilder);
+ }
+ }
+
+ // packet from sf to sff that need to go out local
+ @Override
+ public void program_sfEgress(long dataPathId, int dstPort, boolean write) {
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dataPathId);
+ FlowBuilder flowBuilder = new FlowBuilder();
+
+ MatchBuilder matchBuilder = new MatchBuilder();
+ MatchUtils.createIpProtocolMatch(matchBuilder, UDP_SHORT);
+ MatchUtils.addLayer4Match(matchBuilder, UDP_SHORT, 0, dstPort);
+ MatchUtils.addNxRegMatch(matchBuilder,
+ MatchUtils.RegMatch.of(FlowUtils.REG_FIELD, FlowUtils.REG_VALUE_FROM_LOCAL));
+ flowBuilder.setMatch(matchBuilder.build());
+
+ String flowId = "sfEgress_" + dstPort;
+ flowBuilder.setId(new FlowId(flowId));
+ FlowKey key = new FlowKey(new FlowId(flowId));
+ flowBuilder.setBarrier(true);
+ flowBuilder.setTableId(getTable());
+ flowBuilder.setKey(key);
+ flowBuilder.setFlowName(flowId);
+ flowBuilder.setHardTimeout(0);
+ flowBuilder.setIdleTimeout(0);
+ flowBuilder.setCookie(new FlowCookie(getCookie(FlowID.FLOW_SFEGRESS)));
+ flowBuilder.setCookieMask(new FlowCookie(getCookie(FlowID.FLOW_SFEGRESS)));
+
+ if (write) {
+ InstructionBuilder ib = new InstructionBuilder();
+ InstructionsBuilder isb = new InstructionsBuilder();
+ List<Instruction> instructions = Lists.newArrayList();
+ InstructionUtils.createLocalInstructions(ib, dataPathId);
+ ib.setOrder(0);
+ ib.setKey(new InstructionKey(0));
+ instructions.add(ib.build());
+
+ isb.setInstruction(instructions);
+ flowBuilder.setInstructions(isb.build());
+ writeFlow(flowBuilder, nodeBuilder);
+ } else {
+ removeFlow(flowBuilder, nodeBuilder);
+ }
+ }
+
+ // looped back sff to sf packets
+ @Override
+ public void program_sfIngress(long dataPathId, int dstPort, long sfOfPort,
+ String ipAddress, String sfDplName, boolean write) {
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dataPathId);
+ FlowBuilder flowBuilder = new FlowBuilder();
+
+ MatchBuilder matchBuilder = new MatchBuilder();
+ MatchUtils.createIpProtocolMatch(matchBuilder, UDP_SHORT);
+ Ipv4Prefix ipCidr = MatchUtils.iPv4PrefixFromIPv4Address(ipAddress);
+ MatchUtils.createDstL3IPv4Match(matchBuilder, new Ipv4Prefix(ipCidr));
+ MatchUtils.addLayer4Match(matchBuilder, UDP_SHORT, 0, dstPort);
+ flowBuilder.setMatch(matchBuilder.build());
+
+ String flowId = "sfIngress_" + dstPort + "_" + ipAddress;
+ flowBuilder.setId(new FlowId(flowId));
+ FlowKey key = new FlowKey(new FlowId(flowId));
+ flowBuilder.setBarrier(true);
+ flowBuilder.setTableId(TABLE_0);
+ flowBuilder.setKey(key);
+ flowBuilder.setFlowName(flowId);
+ flowBuilder.setHardTimeout(0);
+ flowBuilder.setIdleTimeout(0);
+ flowBuilder.setCookie(new FlowCookie(getCookie(FlowID.FLOW_SFINGRESS)));
+ flowBuilder.setCookieMask(new FlowCookie(getCookie(FlowID.FLOW_SFINGRESS)));
+
+ if (write) {
+ InstructionBuilder ib = new InstructionBuilder();
+ InstructionsBuilder isb = new InstructionsBuilder();
+ List<Instruction> instructions = Lists.newArrayList();
+ InstructionUtils.createOutputPortInstructions(ib, dataPathId, sfOfPort);
+
+ ib.setOrder(0);
+ ib.setKey(new InstructionKey(0));
+ instructions.add(ib.build());
+
+ isb.setInstruction(instructions);
+ flowBuilder.setInstructions(isb.build());
+ writeFlow(flowBuilder, nodeBuilder);
+ } else {
+ removeFlow(flowBuilder, nodeBuilder);
+ }
+ }
+
+ @Override
+ public void programStaticArpEntry(long dataPathId, long ofPort, String macAddressStr,
+ String ipAddress, boolean write) {
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dataPathId);
+ FlowBuilder flowBuilder = new FlowBuilder();
+
+ MacAddress macAddress = new MacAddress(macAddressStr);
+
+ MatchBuilder matchBuilder = new MatchBuilder();
+ MatchUtils.createInPortReservedMatch(matchBuilder, dataPathId, OutputPortValues.LOCAL.toString());
+ MatchUtils.createEtherTypeMatch(matchBuilder, new EtherType(Constants.ARP_ETHERTYPE));
+ MatchUtils.createArpDstIpv4Match(matchBuilder, MatchUtils.iPv4PrefixFromIPv4Address(ipAddress));
+ flowBuilder.setMatch(matchBuilder.build());
+
+ String flowId = "ArpResponder_" + ipAddress;
+ flowBuilder.setId(new FlowId(flowId));
+ FlowKey key = new FlowKey(new FlowId(flowId));
+ flowBuilder.setBarrier(true);
+ flowBuilder.setTableId(TABLE_0);
+ flowBuilder.setKey(key);
+ flowBuilder.setPriority(1024);
+ flowBuilder.setFlowName(flowId);
+ flowBuilder.setHardTimeout(0);
+ flowBuilder.setIdleTimeout(0);
+ flowBuilder.setCookie(new FlowCookie(getCookie(FlowID.FLOW_SFARP)));
+ flowBuilder.setCookieMask(new FlowCookie(getCookie(FlowID.FLOW_SFARP)));
+
+ if (write == true) {
+ InstructionBuilder ib = new InstructionBuilder();
+ InstructionsBuilder isb = new InstructionsBuilder();
+ List<Instruction> instructions = Lists.newArrayList();
+ ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ ActionBuilder ab = new ActionBuilder();
+ List<Action> actionList = Lists.newArrayList();
+
+ // Move Eth Src to Eth Dst
+ ab.setAction(ActionUtils.nxMoveEthSrcToEthDstAction());
+ ab.setOrder(0);
+ ab.setKey(new ActionKey(0));
+ actionList.add(ab.build());
+
+ // Set Eth Src
+ ab.setAction(ActionUtils.setDlSrcAction(new MacAddress(macAddress)));
+ ab.setOrder(1);
+ ab.setKey(new ActionKey(1));
+ actionList.add(ab.build());
+
+ // Set ARP OP
+ ab.setAction(ActionUtils.nxLoadArpOpAction(BigInteger.valueOf(FlowUtils.ARP_OP_REPLY)));
+ ab.setOrder(2);
+ ab.setKey(new ActionKey(2));
+ actionList.add(ab.build());
+
+ // Move ARP SHA to ARP THA
+ ab.setAction(ActionUtils.nxMoveArpShaToArpThaAction());
+ ab.setOrder(3);
+ ab.setKey(new ActionKey(3));
+ actionList.add(ab.build());
+
+ // Move ARP SPA to ARP TPA
+ ab.setAction(ActionUtils.nxMoveArpSpaToArpTpaAction());
+ ab.setOrder(4);
+ ab.setKey(new ActionKey(4));
+ actionList.add(ab.build());
+
+ // Load Mac to ARP SHA
+ ab.setAction(ActionUtils.nxLoadArpShaAction(macAddress));
+ ab.setOrder(5);
+ ab.setKey(new ActionKey(5));
+ actionList.add(ab.build());
+
+ // Load IP to ARP SPA
+ ab.setAction(ActionUtils.nxLoadArpSpaAction(ipAddress));
+ ab.setOrder(6);
+ ab.setKey(new ActionKey(6));
+ actionList.add(ab.build());
+
+ // Output of InPort
+ ab.setAction(ActionUtils.outputAction(
+ FlowUtils.getSpecialNodeConnectorId(dataPathId, OutputPortValues.INPORT.toString())));
+ ab.setOrder(7);
+ ab.setKey(new ActionKey(7));
+ actionList.add(ab.build());
+
+ // Create Apply Actions Instruction
+ aab.setAction(actionList);
+ ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+ ib.setOrder(0);
+ ib.setKey(new InstructionKey(0));
+ instructions.add(ib.build());
+
+ isb.setInstruction(instructions);
+ flowBuilder.setInstructions(isb.build());
+ writeFlow(flowBuilder, nodeBuilder);
+ } else {
+ removeFlow(flowBuilder, nodeBuilder);
+ }
+ }
+
+ private List<Action> getNshAction(NshUtils header, List<Action> actionList) {
+ // Build the Actions to Add the NSH Header
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nshC1Load =
+ ActionUtils.nxLoadNshc1RegAction(header.getNshMetaC1());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nshC2Load =
+ ActionUtils.nxLoadNshc2RegAction(header.getNshMetaC2());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nspLoad =
+ ActionUtils.nxSetNspAction(header.getNshNsp());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nsiLoad =
+ ActionUtils.nxSetNsiAction(header.getNshNsi());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action loadChainTunVnid =
+ ActionUtils.nxLoadTunIdAction(BigInteger.valueOf(header.getNshNsp()), false);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action loadChainTunDest =
+ ActionUtils.nxLoadTunIPv4Action(header.getNshTunIpDst().getValue(), false);
+
+ int count = actionList.size();
+ actionList.add(new ActionBuilder()
+ .setKey(new ActionKey(count)).setOrder(count++).setAction(nshC1Load).build());
+ //actionList.add(new ActionBuilder()
+ // .setKey(new ActionKey(count)).setOrder(count++).setAction(nshC2Load).build());
+ actionList.add(new ActionBuilder()
+ .setKey(new ActionKey(count)).setOrder(count++).setAction(nspLoad).build());
+ actionList.add(new ActionBuilder()
+ .setKey(new ActionKey(count)).setOrder(count++).setAction(nsiLoad).build());
+ actionList.add(new ActionBuilder()
+ .setKey(new ActionKey(count)).setOrder(count++).setAction(loadChainTunDest).build());
+ actionList.add(new ActionBuilder()
+ .setKey(new ActionKey(count)).setOrder(count).setAction(loadChainTunVnid).build());
+ return actionList;
+ }
+
+ public MatchBuilder buildMatch(Matches matches) {
+ MatchBuilder matchBuilder = new MatchBuilder();
+
+ if (matches.getAceType() instanceof AceIp) {
+ AceIp aceIp = (AceIp)matches.getAceType();
+ if (aceIp.getAceIpVersion() instanceof AceIpv4) {
+ //AceIpv4 aceIpv4 = (AceIpv4) aceIp.getAceIpVersion();
+ //MatchUtils.createSrcL3IPv4Match(matchBuilder, aceIpv4.getSourceIpv4Network());
+ //MatchUtils.createDstL3IPv4Match(matchBuilder, aceIpv4.getDestinationIpv4Network());
+ MatchUtils.createIpProtocolMatch(matchBuilder, aceIp.getProtocol());
+ MatchUtils.addLayer4Match(matchBuilder, aceIp.getProtocol().intValue(), 0,
+ aceIp.getDestinationPortRange().getLowerPort().getValue().intValue());
+ } else {
+ MatchUtils.createIpProtocolMatch(matchBuilder, aceIp.getProtocol());
+ MatchUtils.addLayer4Match(matchBuilder, aceIp.getProtocol().intValue(), 0,
+ aceIp.getDestinationPortRange().getLowerPort().getValue().intValue());
+ }
+ } else if (matches.getAceType() instanceof AceEth) {
+ AceEth aceEth = (AceEth) matches.getAceType();
+ MatchUtils.createEthSrcMatch(matchBuilder, new MacAddress(aceEth.getSourceMacAddress().getValue()));
+ MatchUtils.createDestEthMatch(matchBuilder, new MacAddress(aceEth.getDestinationMacAddress().getValue()),
+ new MacAddress(aceEth.getDestinationMacAddressMask().getValue()));
+ }
+
+ LOG.info("buildMatch: {}", matchBuilder.build());
+ return matchBuilder;
+ }
+}
+/*
+ * Copyright © 2015 Red Hat, 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.rev141210;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.ovsdb.openstack.netvirt.sfc.NetvirtSfcProvider;
+import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.osgi.framework.BundleContext;
-
-public class NetvirtSfcModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.rev141210.AbstractNetvirtSfcModule {
+public class NetvirtSfcModule extends AbstractNetvirtSfcModule {
private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcModule.class);
+ private BundleContext bundleContext;
- public NetvirtSfcModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ public NetvirtSfcModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
- public NetvirtSfcModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.rev141210.NetvirtSfcModule oldModule, java.lang.AutoCloseable oldInstance) {
+ public NetvirtSfcModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver,
+ NetvirtSfcModule oldModule, java.lang.AutoCloseable oldInstance) {
super(identifier, dependencyResolver, oldModule, oldInstance);
}
@Override
public java.lang.AutoCloseable createInstance() {
LOG.info("Netvirt SFC module initialization.");
- NetvirtSfcProvider sfcProvider = new NetvirtSfcProvider();
+ NetvirtSfcProvider sfcProvider = new NetvirtSfcProvider(bundleContext);
+ sfcProvider.setOf13Provider(getOf13provider());
getBrokerDependency().registerProvider(sfcProvider);
return sfcProvider;
}
+
+ public void setBundleContext(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
}
/*
-* Generated file
-*
-* Generated from: yang module name: netvirt-sfc yang module local name: netvirt-sfc
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Sep 23 15:18:24 EDT 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
+ * Copyright © 2015 Red Hat, 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.rev141210;
import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
-import org.opendaylight.controller.config.spi.Module;
import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-public class NetvirtSfcModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.rev141210.AbstractNetvirtSfcModuleFactory {
+public class NetvirtSfcModuleFactory extends AbstractNetvirtSfcModuleFactory {
+ @Override
+ public NetvirtSfcModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+ BundleContext bundleContext) {
+ NetvirtSfcModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
+
+ @Override
+ public NetvirtSfcModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+ NetvirtSfcModule oldModule, AutoCloseable oldInstance,
+ BundleContext bundleContext) {
+ NetvirtSfcModule module = super.instantiateModule(instanceName, dependencyResolver,
+ oldModule, oldInstance, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
}
}
}
}
+
+ leaf of13provider {
+ type string;
+ }
}
}
}
* 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.rev141210;
+import java.util.Dictionary;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.opendaylight.controller.config.api.DependencyResolver;
import org.opendaylight.controller.config.api.JmxAttribute;
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.AbstractServiceInstance;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.PipelineOrchestrator;
import org.opendaylight.ovsdb.openstack.netvirt.sfc.NetvirtSfcProvider;
-import org.osgi.framework.BundleContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import javax.management.ObjectName;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.standalone.openflow13.services.SfcClassifierService;
+import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@PrepareForTest(ServiceHelper.class)
+@RunWith(PowerMockRunner.class)
public class NetvirtSfcModuleTest {
@Test
public void testCustomValidation() {
module.customValidation();
}
+ @SuppressWarnings("unchecked")
@Test
public void testCreateInstance() throws Exception {
// configure mocks
BindingAwareBroker broker = mock(BindingAwareBroker.class);
ProviderContext session = mock(ProviderContext.class);
DataBroker dataBroker = mock(DataBroker.class);
- when(dependencyResolver.resolveInstance(eq(BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class))).thenReturn(broker);
+ when(dependencyResolver.resolveInstance(eq(BindingAwareBroker.class),
+ any(ObjectName.class), any(JmxAttribute.class))).thenReturn(broker);
when(session.getSALService(eq(DataBroker.class))).thenReturn(dataBroker);
// create instance of module with injected mocks
NetvirtSfcModule module = new NetvirtSfcModule(mock(ModuleIdentifier.class), dependencyResolver);
// getInstance calls resolveInstance to get the broker dependency and then calls createInstance
+ BundleContext bundleContext = mock(BundleContext.class);
+ PowerMockito.mockStatic(ServiceHelper.class);
+ PipelineOrchestrator pipelineOrchestrator = mock(PipelineOrchestrator.class);
+ PowerMockito.when(ServiceHelper.getGlobalInstance(eq(PipelineOrchestrator.class), any(AbstractServiceInstance.class)))
+ .thenReturn(pipelineOrchestrator);
+ PowerMockito.when(ServiceHelper.getGlobalInstance(eq(Southbound.class), any(AbstractServiceInstance.class)))
+ .thenReturn(mock(Southbound.class));
+
+ doNothing().when(pipelineOrchestrator).registerService(any(ServiceReference.class),
+ any(AbstractServiceInstance.class));
+ when(bundleContext.registerService(
+ eq(new String[]{AbstractServiceInstance.class.getName(), SfcClassifierService.class.getName()}),
+ any(),
+ any(Dictionary.class)))
+ .thenReturn(mock(ServiceRegistration.class));
+ when(bundleContext.getServiceReference(SfcClassifierService.class.getName()))
+ .thenReturn(mock(ServiceReference.class));
AutoCloseable closeable = module.getInstance();
+ ((NetvirtSfcProvider)closeable).setBundleContext(bundleContext);
+ ((NetvirtSfcProvider)closeable).setOf13Provider("standalone");
((NetvirtSfcProvider)closeable).onSessionInitiated(session);
// verify that the module registered the returned provider with the broker
verify(broker).registerProvider((NetvirtSfcProvider)closeable);
<karaf.distro.artifactId>openstack.net-virt-sfc-karaf</karaf.distro.artifactId>
<karaf.distro.version>${project.version}</karaf.distro.version>
<karaf.distro.type>zip</karaf.distro.type>
- </properties>
+ </properties>
<dependencyManagement>
<dependencies>
<artifactId>openstack.net-virt-sfc-features-test</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>utils.mdsal-openflow</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>utils.mdsal-utils</artifactId>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
package org.opendaylight.ovsdb.openstack.netvirt.sfc;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.ops4j.pax.exam.CoreOptions.composite;
import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.propagateSystemProperties;
import static org.ops4j.pax.exam.CoreOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.when;
+import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
+import static org.ops4j.pax.exam.MavenUtils.asInProject;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
+import com.google.common.collect.Maps;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.standalone.openflow13.SfcClassifier;
import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.AclUtils;
import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.ClassifierUtils;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.ServiceFunctionChainUtils;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.ServiceFunctionPathUtils;
import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.SfcUtils;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.ServiceFunctionForwarderUtils;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.ServiceFunctionUtils;
import org.opendaylight.ovsdb.southbound.SouthboundConstants;
import org.opendaylight.ovsdb.southbound.SouthboundUtil;
+import org.opendaylight.ovsdb.utils.mdsal.openflow.FlowUtils;
+import org.opendaylight.ovsdb.utils.mdsal.openflow.MatchUtils;
import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
+import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.AccessLists;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.AccessListsBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.AccessListBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.AccessListEntriesBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.AccessListEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.access.list.entry.ActionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.access.list.entry.MatchesBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunctionBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.ServiceFunctionChains;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.ServiceFunctionChainsBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChain;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChainBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunction;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunctionBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwarders;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwardersBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPaths;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPathsBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Firewall;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.AccessLists;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.AccessListsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.AclBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.AccessListEntriesBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.AceBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.ActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.Matches;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.MatchesBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.Classifiers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.ClassifiersBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.ClassifierBuilder;
private static AclUtils aclUtils = new AclUtils();
private static ClassifierUtils classifierUtils = new ClassifierUtils();
private static SfcUtils sfcUtils = new SfcUtils();
+ private static ServiceFunctionUtils serviceFunctionUtils = new ServiceFunctionUtils();
+ private static ServiceFunctionForwarderUtils serviceFunctionForwarderUtils = new ServiceFunctionForwarderUtils();
+ private static ServiceFunctionChainUtils serviceFunctionChainUtils = new ServiceFunctionChainUtils();
+ private static ServiceFunctionPathUtils serviceFunctionPathUtils = new ServiceFunctionPathUtils();
private static MdsalUtils mdsalUtils;
private static AtomicBoolean setup = new AtomicBoolean(false);
private static SouthboundUtils southboundUtils;
private static String addressStr;
private static String portStr;
private static String connectionType;
+ private static Southbound southbound;
+ private static DataBroker dataBroker;
+ public static final String CONTROLLER_IPADDRESS = "ovsdb.controller.address";
public static final String SERVER_IPADDRESS = "ovsdbserver.ipaddress";
public static final String SERVER_PORT = "ovsdbserver.port";
public static final String CONNECTION_TYPE = "ovsdbserver.connection";
public static final String DEFAULT_SERVER_PORT = "6640";
public static final String INTEGRATION_BRIDGE_NAME = "br-int";
private static final String NETVIRT_TOPOLOGY_ID = "netvirt:1";
+ private static final String OVSDB_TRACE = "ovsdb.trace";
+ private static final String SF1NAME = "firewall-72";
+ private static final String SF2NAME = "dpi-72";
+ private static final String SF1IP = "10.2.1.1";//"192.168.50.70";//"192.168.120.31";
+ private static final String SF2IP = "10.2.1.2";
+ private static final String SF1DPLNAME = "sf1";
+ private static final String SF2DPLNAME = "sf2";
+ private static final String SFF1IP = "127.0.0.1"; //"192.168.1.129"
+ private static final String SFF2IP = "192.168.1.129";//"127.0.0.1";
+ private static final String SFF1NAME = "SFF1";
+ private static final String SFF2NAME = "SFF2";
+ private static final String SFFDPL1NAME = "vxgpe";
+ private static final String SFFDPL2NAME = "vxgpe";
+ private static final String SN1NAME = "OVSDB1";
+ private static final String SN2NAME = "OVSDB2";
+ private static final String BRIDGE1NAME= "br-int";
+ private static final String BRIDGE2NAME= "br-int";
+ private static final String ACLNAME= "httpAcl";
+ private static final String SFCNAME = "SFC";
+ private static final int GPEPORT = 6633;
@Override
public String getModuleName() {
private Option[] getOtherOptions() {
return new Option[] {
+ wrappedBundle(
+ mavenBundle("org.opendaylight.ovsdb", "utils.mdsal-openflow")
+ .version(asInProject())
+ .type("jar")),
+ configureConsole().startLocalConsole(),
vmOption("-javaagent:../jars/org.jacoco.agent.jar=destfile=../../jacoco-it.exec"),
- keepRuntimeFolder()
+ keepRuntimeFolder()
};
}
public Option[] getPropertiesOptions() {
return new Option[] {
- propagateSystemProperties(SERVER_IPADDRESS, SERVER_PORT, CONNECTION_TYPE),
+ propagateSystemProperties(SERVER_IPADDRESS, SERVER_PORT, CONNECTION_TYPE,
+ CONTROLLER_IPADDRESS, OVSDB_TRACE),
};
}
@Override
public Option getLoggingOption() {
return composite(
+ when(Boolean.getBoolean(OVSDB_TRACE)).useOptions(
+ editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
+ "log4j.logger.org.opendaylight.ovsdb",
+ LogLevelOption.LogLevel.TRACE.name())),
+ //editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
+ // "log4j.logger.org.opendaylight.ovsdb",
+ // LogLevelOption.LogLevel.TRACE.name()),
editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
logConfiguration(NetvirtSfcIT.class),
LogLevel.INFO.name()),
editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
"log4j.logger.org.opendaylight.ovsdb.openstack.netvirt.sfc",
- LogLevel.INFO.name()),
- /*editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
- "log4j.logger.org.opendaylight.ovsdb",
- LogLevelOption.LogLevel.TRACE.name()),*/
+ LogLevel.TRACE.name()),
+ editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
+ "log4j.logger.org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13",
+ LogLevel.TRACE.name()),
+ editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
+ "log4j.logger.org.opendaylight.sfc",
+ LogLevel.TRACE.name()),
super.getLoggingOption());
}
fail(usage());
}
}
+ LOG.info("getProperties {}: {}", OVSDB_TRACE, props.getProperty(OVSDB_TRACE));
}
@Before
getProperties();
- DataBroker dataBroker = getDatabroker(getProviderContext());
+ dataBroker = getDatabroker(getProviderContext());
mdsalUtils = new MdsalUtils(dataBroker);
assertNotNull("mdsalUtils should not be null", mdsalUtils);
southboundUtils = new SouthboundUtils(mdsalUtils);
assertTrue("Did not find " + NETVIRT_TOPOLOGY_ID, getNetvirtTopology());
+ southbound = (Southbound) ServiceHelper.getGlobalInstance(Southbound.class, this);
+ assertNotNull("southbound should not be null", southbound);
setup.set(true);
}
assertTrue(true);
}
- private AccessListsBuilder setAccessLists () {
- MatchesBuilder matchesBuilder = aclUtils.createMatches(new MatchesBuilder(), 80);
- ActionsBuilder actionsBuilder = aclUtils.createActions(new ActionsBuilder(), Boolean.TRUE);
- AccessListEntryBuilder accessListEntryBuilder = aclUtils.createAccessListEntryBuilder(
- new AccessListEntryBuilder(), "http", matchesBuilder, actionsBuilder);
- AccessListEntriesBuilder accessListEntriesBuilder = aclUtils.createAccessListEntries(
- new AccessListEntriesBuilder(), accessListEntryBuilder);
- AccessListBuilder accessListBuilder = aclUtils.createAccessList(new AccessListBuilder(),
- "http", accessListEntriesBuilder);
- AccessListsBuilder accessListsBuilder = aclUtils.createAccessLists(new AccessListsBuilder(),
- accessListBuilder);
+ private AccessListsBuilder accessListsBuilder() {
+ MatchesBuilder matchesBuilder = aclUtils.matchesBuilder(new MatchesBuilder(), 80);
+ LOG.info("Matches: {}", matchesBuilder.build());
+ //ActionsBuilder actionsBuilder = aclUtils.actionsBuilder(new ActionsBuilder(), Boolean.TRUE);
+ ActionsBuilder actionsBuilder = aclUtils.actionsBuilder(new ActionsBuilder(), SFCNAME);
+ AceBuilder accessListEntryBuilder =
+ aclUtils.aceBuilder(new AceBuilder(), "httpRule", matchesBuilder, actionsBuilder);
+ AccessListEntriesBuilder accessListEntriesBuilder =
+ aclUtils.accessListEntriesBuidler(new AccessListEntriesBuilder(), accessListEntryBuilder);
+ AclBuilder accessListBuilder =
+ aclUtils.aclBuilder(new AclBuilder(), ACLNAME, accessListEntriesBuilder);
+ AccessListsBuilder accessListsBuilder =
+ aclUtils.accesslistsbuilder(new AccessListsBuilder(), accessListBuilder);
LOG.info("AccessLists: {}", accessListsBuilder.build());
return accessListsBuilder;
}
@Test
- public void testAccessLists() {
- testModel(setAccessLists(), AccessLists.class);
+ public void testAccessLists() throws InterruptedException {
+ testModel(accessListsBuilder(), AccessLists.class, 0);
}
- private ClassifiersBuilder setClassifiers() {
- SffBuilder sffBuilder = classifierUtils.createSff(new SffBuilder(), "sffname");
- SffsBuilder sffsBuilder = classifierUtils.createSffs(new SffsBuilder(), sffBuilder);
- ClassifierBuilder classifierBuilder = classifierUtils.createClassifier(new ClassifierBuilder(),
- "classifierName", "aclName", sffsBuilder);
- ClassifiersBuilder classifiersBuilder = classifierUtils.createClassifiers(new ClassifiersBuilder(),
+ private ClassifiersBuilder classifiersBuilder() {
+ SffBuilder sffBuilder = classifierUtils.sffBuilder(new SffBuilder(), SFF1NAME);
+ SffsBuilder sffsBuilder = classifierUtils.sffsBuilder(new SffsBuilder(), sffBuilder);
+ ClassifierBuilder classifierBuilder = classifierUtils.classifierBuilder(new ClassifierBuilder(),
+ "classifierName", ACLNAME, sffsBuilder);
+ ClassifiersBuilder classifiersBuilder = classifierUtils.ClassifiersBuilder(new ClassifiersBuilder(),
classifierBuilder);
LOG.info("Classifiers: {}", classifiersBuilder.build());
return classifiersBuilder;
}
@Test
- public void testClassifiers() {
- testModel(setClassifiers(), Classifiers.class);
+ public void testClassifiers() throws InterruptedException {
+ testModel(classifiersBuilder(), Classifiers.class, 0);
}
- private SfcBuilder setSfc() {
- SfcBuilder sfcBuilder = sfcUtils.createSfc(new SfcBuilder(), "sfc");
- return sfcBuilder;
+ private SfcBuilder netvirtSfcBuilder() {
+ return sfcUtils.sfcBuilder(new SfcBuilder(), "sfc");
}
@Test
- public void testSfc() {
- testModel(setSfc(), Sfc.class);
+ public void testNetvirtSfcModel() throws InterruptedException {
+ testModel(netvirtSfcBuilder(), Sfc.class, 0);
}
- private <T extends DataObject> void testModel(Builder<T> builder, Class<T> clazz) {
+ private <T extends DataObject> void testModelPut(Builder<T> builder, Class<T> clazz) {
InstanceIdentifier<T> path = InstanceIdentifier.create(clazz);
assertTrue(mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, path, builder.build()));
T result = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path);
assertNotNull(clazz.getSimpleName() + " should not be null", result);
+ }
+
+ private <T extends DataObject> void testModelDelete(Builder<T> builder, Class<T> clazz)
+ throws InterruptedException {
+ InstanceIdentifier<T> path = InstanceIdentifier.create(clazz);
assertTrue("Failed to remove " + clazz.getSimpleName(),
mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, path));
- result = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path);
+ T result = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path);
assertNull(clazz.getSimpleName() + " should be null", result);
}
+ private <T extends DataObject> void testModel(Builder<T> builder, Class<T> clazz, long wait)
+ throws InterruptedException {
+ testModelPut(builder, clazz);
+ Thread.sleep(wait);
+ testModelDelete(builder, clazz);
+ }
+
+ private ServiceFunctionsBuilder serviceFunctionsBuilder() {
+ String sf1Name = SF1NAME;
+ String sf1Ip = SF1IP;
+ String sff1Ip = SF1IP;
+ String sff1Name = SFF1NAME;
+ String sf1DplName = SF1DPLNAME;
+ String sn1Name = SN1NAME;
+ String bridge1Name= BRIDGE1NAME;
+ String sf2Name = SF2NAME;
+ String sf2Ip = SF2IP;
+ String sff2Ip = SF2IP;
+ String sff2Name = SFF2NAME;
+ String sf2DplName = SF2DPLNAME;
+ String sn2Name = SN2NAME;
+ String bridge2Name= BRIDGE2NAME;
+ int port = GPEPORT;
+
+ ServiceFunctionBuilder serviceFunctionBuilder =
+ serviceFunctionUtils.serviceFunctionBuilder(sf1Ip, port, sf1DplName, sff1Name, sf1Name);
+ List<ServiceFunction> serviceFunctionList = serviceFunctionUtils.list(
+ new ArrayList<ServiceFunction>(), serviceFunctionBuilder);
+
+ //serviceFunctionBuilder =
+ // serviceFunctionUtils.serviceFunctionBuilder(sf2Ip, port, sffDpl2Name, sff2Name, sf2Name);
+ //serviceFunctionList = serviceFunctionUtils.list(
+ // serviceFunctionList, serviceFunctionBuilder);
+
+ ServiceFunctionsBuilder serviceFunctionsBuilder =
+ serviceFunctionUtils.serviceFunctionsBuilder(new ServiceFunctionsBuilder(),
+ serviceFunctionList);
+ LOG.info("ServiceFunctions: {}", serviceFunctionsBuilder.build());
+ return serviceFunctionsBuilder;
+ }
+
+ private ServiceFunctionForwardersBuilder serviceFunctionForwardersBuilder() {
+ String sf1Name = SF1NAME;
+ String sf1Ip = SF1IP;
+ String sff1Ip = SFF1IP;
+ String sff1Name = SFF1NAME;
+ String sffDpl1Name = SFFDPL1NAME;
+ String sn1Name = SN1NAME;
+ String bridge1Name= BRIDGE1NAME;
+ String sf2Name = SF2NAME;
+ String sf2Ip = SF2IP;
+ String sff2Ip = SFF2IP;
+ String sff2Name = SFF2NAME;
+ String sffDpl2Name = SFFDPL2NAME;
+ String sn2Name = SN2NAME;
+ String bridge2Name= BRIDGE2NAME;
+ String aclName = ACLNAME;
+ int port = GPEPORT;
+
+ ServiceFunctionForwarderBuilder serviceFunctionForwarderBuilder =
+ serviceFunctionForwarderUtils.serviceFunctionForwarderBuilder(
+ sff1Name, sff1Ip, port, sffDpl1Name, sf1Name, sf1Ip, sn1Name, bridge1Name, Firewall.class);
+ List<ServiceFunctionForwarder> serviceFunctionForwarderList = serviceFunctionForwarderUtils.list(
+ new ArrayList<ServiceFunctionForwarder>(), serviceFunctionForwarderBuilder);
+
+ //serviceFunctionForwarderBuilder =
+ // serviceFunctionForwarderUtils.serviceFunctionForwarderBuilder(
+ // sff2Name, sff2Ip, port, sffDpl2Name, sf2Name, sff2Ip, sn2Name, bridge2Name, Dpi.class);
+ //serviceFunctionForwarderList = serviceFunctionForwarderUtils.list(
+ // serviceFunctionForwarderList, serviceFunctionForwarderBuilder);
+
+ ServiceFunctionForwardersBuilder serviceFunctionForwardersBuilder =
+ serviceFunctionForwarderUtils.serviceFunctionForwardersBuilder(
+ new ServiceFunctionForwardersBuilder(), serviceFunctionForwarderList);
+ LOG.info("ServiceFunctionForwarders: {}", serviceFunctionForwardersBuilder.build());
+ return serviceFunctionForwardersBuilder;
+ }
+
+ private ServiceFunctionChainsBuilder serviceFunctionChainsBuilder() {
+ String sf1Name = "firewall-abstract1";
+ String sf2Name = "dpi-abstract1";
+ String sfcName = SFCNAME;
+
+ SfcServiceFunctionBuilder sfcServiceFunctionBuilder = serviceFunctionChainUtils.sfcServiceFunctionBuilder(
+ new SfcServiceFunctionBuilder(), sf1Name, Firewall.class);
+ List<SfcServiceFunction> sfcServiceFunctionList =
+ serviceFunctionChainUtils.list(new ArrayList<SfcServiceFunction>(), sfcServiceFunctionBuilder);
+
+ //sfcServiceFunctionBuilder = serviceFunctionChainUtils.sfcServiceFunctionBuilder(
+ // sfcServiceFunctionBuilder, sf2Name, Dpi.class);
+ //sfcServiceFunctionList = serviceFunctionChainUtils.list(sfcServiceFunctionList, sfcServiceFunctionBuilder);
+
+ ServiceFunctionChainBuilder serviceFunctionChainBuilder =
+ serviceFunctionChainUtils.serviceFunctionChainBuilder(
+ new ServiceFunctionChainBuilder(), sfcName, false, sfcServiceFunctionList);
+ ServiceFunctionChainsBuilder serviceFunctionChainsBuilder =
+ serviceFunctionChainUtils.serviceFunctionChainsBuilder(
+ new ServiceFunctionChainsBuilder(),
+ serviceFunctionChainUtils.list(new ArrayList<ServiceFunctionChain>(),
+ serviceFunctionChainBuilder));
+ LOG.info("ServiceFunctionChains: {}", serviceFunctionChainBuilder.build());
+ return serviceFunctionChainsBuilder;
+ }
+
+ private ServiceFunctionPathsBuilder serviceFunctionPathsBuilder() {
+ String sfpName = "SFC-Path";
+ String sfcName = "SFC";
+ short startingIndex = 255;
+
+ ServiceFunctionPathBuilder serviceFunctionPathBuilder =
+ serviceFunctionPathUtils.serviceFunctionPathBuilder(
+ new ServiceFunctionPathBuilder(), sfpName, sfcName, startingIndex, false);
+ ServiceFunctionPathsBuilder serviceFunctionPathsBuilder =
+ serviceFunctionPathUtils.serviceFunctionPathsBuilder(
+ serviceFunctionPathUtils.list(new ArrayList<ServiceFunctionPath>(),
+ serviceFunctionPathBuilder));
+ LOG.info("ServiceFunctionPaths: {}", serviceFunctionPathsBuilder.build());
+ return serviceFunctionPathsBuilder;
+ }
+
+ @Test
+ public void testSfcModel() throws InterruptedException {
+ testModel(serviceFunctionsBuilder(), ServiceFunctions.class, 3000);
+ testModel(serviceFunctionForwardersBuilder(), ServiceFunctionForwarders.class, 3000);
+ testModel(serviceFunctionChainsBuilder(), ServiceFunctionChains.class, 3000);
+ testModel(serviceFunctionPathsBuilder(), ServiceFunctionPaths.class, 3000);
+ }
+
+ @Test
+ public void testSfcModels() throws InterruptedException {
+ String bridgeName = INTEGRATION_BRIDGE_NAME;
+ ConnectionInfo connectionInfo = southboundUtils.getConnectionInfo(addressStr, portStr);
+ assertNotNull("connection failed", southboundUtils.connectOvsdbNode(connectionInfo));
+ Node ovsdbNode = southboundUtils.getOvsdbNode(connectionInfo);
+ assertNotNull("node is not connected", ovsdbNode);
+
+ Thread.sleep(5000);
+ Node bridgeNode = southbound.getBridgeNode(ovsdbNode, bridgeName);
+ assertNotNull("bridge " + bridgeName + " was not found", bridgeNode);
+ long datapathId = southbound.getDataPathId(bridgeNode);
+
+ Map<String, String> externalIds = Maps.newHashMap();
+ externalIds.put("attached-mac", "f6:00:00:0f:00:01");
+ southboundUtils.addTerminationPoint(bridgeNode, null, SF1DPLNAME, "internal", null, externalIds);
+ southboundUtils.addTerminationPoint(bridgeNode, null, "vm1", "internal");
+ southboundUtils.addTerminationPoint(bridgeNode, null, "vm2", "internal");
+ Map<String, String> options = Maps.newHashMap();
+ options.put("key", "flow");
+ options.put("remote_ip", "192.168.120.32");
+ southboundUtils.addTerminationPoint(bridgeNode, null, "vx", "vxlan", options, null);
+ Thread.sleep(1000);
+
+ testModelPut(serviceFunctionsBuilder(), ServiceFunctions.class);
+ testModelPut(serviceFunctionForwardersBuilder(), ServiceFunctionForwarders.class);
+ testModelPut(serviceFunctionChainsBuilder(), ServiceFunctionChains.class);
+ testModelPut(serviceFunctionPathsBuilder(), ServiceFunctionPaths.class);
+
+ Thread.sleep(5000);
+
+ testModelPut(accessListsBuilder(), AccessLists.class);
+ testModelPut(classifiersBuilder(), Classifiers.class);
+
+ Thread.sleep(10000);
+
+ ISfcClassifierService sfcClassifierService = (ISfcClassifierService) ServiceHelper.getGlobalInstance(ISfcClassifierService.class, this);
+ LOG.info("SfcClassifierService: {}", sfcClassifierService);
+ readwait();
+ //sfcClassifierService.programIngressClassifier(datapathId);
+
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(datapathId);
+ FlowBuilder flowBuilder = getSfcIngressClassifierFlowBuilder();
+ Flow flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.CONFIGURATION);
+ assertNotNull("Could not find flow in config", flow);
+ flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.OPERATIONAL);
+ assertNotNull("Could not find flow in operational", flow);
+
+ assertTrue(southboundUtils.deleteBridge(connectionInfo, bridgeName));
+ Thread.sleep(1000);
+ assertTrue(southboundUtils.disconnectOvsdbNode(connectionInfo));
+ }
+
/*
* Connect to an ovsdb node. Netvirt should add br-int, add the controller address
* and program the pipeline flows.
*/
@Test
- public void testDoIt() throws InterruptedException {
+ public void testNetvirtSfc() throws InterruptedException {
+ String bridgeName = INTEGRATION_BRIDGE_NAME;
ConnectionInfo connectionInfo = southboundUtils.getConnectionInfo(addressStr, portStr);
assertNotNull("connection failed", southboundUtils.connectOvsdbNode(connectionInfo));
- assertNotNull("node is not connected", southboundUtils.getOvsdbNode(connectionInfo));
+ Node ovsdbNode = southboundUtils.getOvsdbNode(connectionInfo);
+ assertNotNull("node is not connected", ovsdbNode);
ControllerEntry controllerEntry;
// Loop 10s checking if the controller was added
for (int i = 0; i < 10; i++) {
- Node ovsdbNode = southboundUtils.getOvsdbNode(connectionInfo);
+ ovsdbNode = southboundUtils.getOvsdbNode(connectionInfo);
assertNotNull("ovsdb node not found", ovsdbNode);
String controllerTarget = SouthboundUtil.getControllerTarget(ovsdbNode);
assertNotNull("Failed to get controller target", controllerTarget);
- OvsdbBridgeAugmentation bridge = southboundUtils.getBridge(connectionInfo, INTEGRATION_BRIDGE_NAME);
+ OvsdbBridgeAugmentation bridge = southboundUtils.getBridge(connectionInfo, bridgeName);
+ if (bridge != null) {
+ assertNotNull("Failed to read bridge", bridge);
+ assertNotNull("Failed to extract controllerEntry", bridge.getControllerEntry());
+ controllerEntry = bridge.getControllerEntry().iterator().next();
+ assertEquals(controllerTarget, controllerEntry.getTarget().getValue());
+ if (controllerEntry.isIsConnected()) {
+ Assert.assertTrue("switch is not connected to the controller", controllerEntry.isIsConnected());
+ break;
+ }
+ }
+ Thread.sleep(1000);
+ }
+
+ Node bridgeNode = southbound.getBridgeNode(ovsdbNode, bridgeName);
+ assertNotNull("bridge " + bridgeName + " was not found", bridgeNode);
+ long datapathId = southbound.getDataPathId(bridgeNode);
+
+ //Thread.sleep(10000);
+
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(datapathId);
+ FlowBuilder flowBuilder = FlowUtils.getPipelineFlow(Service.SFC_CLASSIFIER.getTable(), (short)0);
+ Flow flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.CONFIGURATION);
+ assertNotNull("Could not find flow in config", flow);
+ flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.OPERATIONAL);
+ assertNotNull("Could not find flow in operational", flow);
+
+ assertTrue(southboundUtils.deleteBridge(connectionInfo, bridgeName));
+ Thread.sleep(1000);
+ assertTrue(southboundUtils.disconnectOvsdbNode(connectionInfo));
+ }
+
+ @Ignore
+ @Test
+ public void testStandalone() throws InterruptedException {
+ String bridgeName = "sw1";
+ ConnectionInfo connectionInfo = southboundUtils.getConnectionInfo(addressStr, portStr);
+ assertNotNull("connection failed", southboundUtils.connectOvsdbNode(connectionInfo));
+ Node ovsdbNode = southboundUtils.getOvsdbNode(connectionInfo);
+ assertNotNull("node is not connected", ovsdbNode);
+ String controllerTarget = "tcp:192.168.50.1:6653";
+ List<ControllerEntry> setControllerEntry = southboundUtils.createControllerEntry(controllerTarget);
+ Assert.assertTrue(southboundUtils.addBridge(connectionInfo, null, bridgeName, null, true,
+ SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"), true, null, null,
+ setControllerEntry, null, "00:00:00:00:00:00:00:01"));
+ // Loop 10s checking if the controller was added
+ for (int i = 0; i < 10; i++) {
+ ovsdbNode = southboundUtils.getOvsdbNode(connectionInfo);
+ assertNotNull("ovsdb node not found", ovsdbNode);
+ assertNotNull("Failed to get controller target", controllerTarget);
+ OvsdbBridgeAugmentation bridge = southboundUtils.getBridge(connectionInfo, bridgeName);
assertNotNull(bridge);
assertNotNull(bridge.getControllerEntry());
- controllerEntry = bridge.getControllerEntry().iterator().next();
+ ControllerEntry controllerEntry = bridge.getControllerEntry().iterator().next();
assertEquals(controllerTarget, controllerEntry.getTarget().getValue());
if (controllerEntry.isIsConnected()) {
Assert.assertTrue(controllerEntry.isIsConnected());
Thread.sleep(1000);
}
- /* TODO: add code to write to mdsal to exercise the sfc dataChangeListener */
- /* allow some time to let the impl code do it's work to push flows */
- /* or just comment out below lines and just manually verify on the bridges and reset them */
- //Thread.sleep(10000);
-
+ Node bridgeNode = southbound.getBridgeNode(ovsdbNode, bridgeName);
+ assertNotNull("bridge " + bridgeName + " was not found", bridgeNode);
+ long datapathId = southbound.getDataPathId(bridgeNode);
+
+ SfcClassifier sfcClassifier = new SfcClassifier(dataBroker, southbound, mdsalUtils);
+ //sfcClassifier.programLocalInPort(datapathId, "4096", (long)1, (short)0, (short)50, true);
+
+ NshUtils nshUtils = new NshUtils(new Ipv4Address("192.168.50.71"), new PortNumber(6633),
+ (long)10, (short)255, (long)4096, (long)4096);
+ MatchesBuilder matchesBuilder = aclUtils.matchesBuilder(new MatchesBuilder(), 80);
+ sfcClassifier.programSfcClassiferFlows(datapathId, (short)0, "test", matchesBuilder.build(),
+ nshUtils, (long)2, true);
+
+ nshUtils = new NshUtils(null, null, (long)10, (short)253, 0, 0);
+ //sfcClassifier.programEgressSfcClassiferFlows(datapathId, (short)0, "test", null,
+ // nshUtils, (long)2, (long)3, true);
+
+ //try {
+ // System.in.read();
+ //} catch (IOException e) {
+ // e.printStackTrace();
+ //}
+
+ //NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(datapathId);
+ //FlowBuilder flowBuilder = getLocalInPortFlow(datapathId, "4096", (long) 1, (short) 0);
+ //Flow flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.CONFIGURATION);
+ //assertNotNull("Could not find flow in config", flow);
+ //flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.OPERATIONAL);
+ //assertNotNull("Could not find flow in operational", flow);
+
+ MatchBuilder matchBuilder = sfcClassifier.buildMatch(matchesBuilder.build());
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(datapathId);
+ FlowBuilder flowBuilder = getSfcClassifierFlow(datapathId, (short) 0, "test", null,
+ nshUtils, (long) 2, matchBuilder);
+ Flow flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.CONFIGURATION);
+ assertNotNull("Could not find flow in config", flow);
+ flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.OPERATIONAL);
+ assertNotNull("Could not find flow in operational", flow);
+
+ //nodeBuilder = FlowUtils.createNodeBuilder(datapathId);
+ //flowBuilder = getEgressSfcClassifierFlow(datapathId, (short) 0, "test", nshUtils, (long) 2);
+ //flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.CONFIGURATION);
+ //assertNotNull("Could not find flow in config", flow);
+ //flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.OPERATIONAL);
+ //assertNotNull("Could not find flow in operational", flow);
+
+ LOG.info("***** Go look for flows *****");
+ Thread.sleep(30000);
+ assertTrue(southboundUtils.deleteBridge(connectionInfo, bridgeName));
+ Thread.sleep(1000);
assertTrue(southboundUtils.deleteBridge(connectionInfo, INTEGRATION_BRIDGE_NAME));
Thread.sleep(1000);
assertTrue(southboundUtils.disconnectOvsdbNode(connectionInfo));
}
+
+ private FlowBuilder getLocalInPortFlow(long dpidLong, String segmentationId, long inPort, short writeTable) {
+ MatchBuilder matchBuilder = new MatchBuilder();
+
+ FlowBuilder flowBuilder = new FlowBuilder();
+
+ flowBuilder.setMatch(MatchUtils.createInPortMatch(matchBuilder, dpidLong, inPort).build());
+ String flowId = "sfcIngress_" + segmentationId + "_" + inPort;
+ flowBuilder.setId(new FlowId(flowId));
+ FlowKey key = new FlowKey(new FlowId(flowId));
+ flowBuilder.setStrict(true);
+ flowBuilder.setBarrier(false);
+ flowBuilder.setTableId(writeTable);
+ flowBuilder.setKey(key);
+ flowBuilder.setFlowName(flowId);
+ flowBuilder.setHardTimeout(0);
+ flowBuilder.setIdleTimeout(0);
+ return flowBuilder;
+ }
+
+ public FlowBuilder getSfcClassifierFlow(long dpidLong, short writeTable, String ruleName, Matches match,
+ NshUtils nshHeader, long tunnelOfPort, MatchBuilder matchBuilder) {
+ FlowBuilder flowBuilder = new FlowBuilder();
+
+ flowBuilder.setMatch(matchBuilder.build());
+
+ String flowId = "sfcClass_" + ruleName + "_" + nshHeader.getNshNsp();
+ flowBuilder.setId(new FlowId(flowId));
+ FlowKey key = new FlowKey(new FlowId(flowId));
+ flowBuilder.setBarrier(true);
+ flowBuilder.setTableId(writeTable);
+ flowBuilder.setKey(key);
+ flowBuilder.setFlowName(flowId);
+ flowBuilder.setHardTimeout(0);
+ flowBuilder.setIdleTimeout(0);
+ return flowBuilder;
+ }
+
+ private FlowBuilder getEgressSfcClassifierFlow(long dpidLong, short writeTable, String ruleName,
+ NshUtils nshHeader, long tunnelOfPort) {
+ FlowBuilder flowBuilder = new FlowBuilder();
+
+ MatchBuilder matchBuilder = new MatchBuilder();
+ flowBuilder.setMatch(MatchUtils.createInPortMatch(matchBuilder, dpidLong, tunnelOfPort).build());
+ flowBuilder.setMatch(
+ MatchUtils.createTunnelIDMatch(matchBuilder, BigInteger.valueOf(nshHeader.getNshNsp())).build());
+ flowBuilder.setMatch(MatchUtils.addNxNspMatch(matchBuilder, nshHeader.getNshNsp()).build());
+ flowBuilder.setMatch(MatchUtils.addNxNsiMatch(matchBuilder, nshHeader.getNshNsi()).build());
+
+ String flowId = "egressSfcClass_" + ruleName + "_" + nshHeader.getNshNsp() + "_" + nshHeader.getNshNsi();
+ flowBuilder.setId(new FlowId(flowId));
+ FlowKey key = new FlowKey(new FlowId(flowId));
+ flowBuilder.setStrict(true);
+ flowBuilder.setBarrier(false);
+ flowBuilder.setTableId(writeTable);
+ flowBuilder.setKey(key);
+ flowBuilder.setFlowName(flowId);
+ flowBuilder.setHardTimeout(0);
+ flowBuilder.setIdleTimeout(0);
+ return flowBuilder;
+ }
+
+ private FlowBuilder getSfcIngressClassifierFlowBuilder() {
+ FlowBuilder flowBuilder = new FlowBuilder();
+ String flowId = "sfcClass_" + "httpRule";
+ flowBuilder.setId(new FlowId(flowId));
+ FlowKey key = new FlowKey(new FlowId(flowId));
+ flowBuilder.setKey(key);
+ flowBuilder.setFlowName(flowId);
+ flowBuilder.setTableId((short)10);
+ return flowBuilder;
+ }
+
+ private Flow getFlow (FlowBuilder flowBuilder, NodeBuilder nodeBuilder, LogicalDatastoreType store)
+ throws InterruptedException {
+ Flow flow = null;
+ for (int i = 0; i < 10; i++) {
+ flow = FlowUtils.getFlow(flowBuilder, nodeBuilder, dataBroker.newReadOnlyTransaction(), store);
+ if (flow != null) {
+ LOG.info("getFlow: flow: {}: {}", store, flow);
+ break;
+ }
+ Thread.sleep(1000);
+ }
+ return flow;
+ }
+
+ private void readwait() {
+ try {
+ System.in.read();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
--- /dev/null
+package org.opendaylight.ovsdb.openstack.netvirt.sfc.utils;
+
+import java.util.List;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.DataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.VxlanGpe;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.data.plane.locator.locator.type.IpBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yangtools.concepts.Builder;
+
+public abstract class AbstractUtils {
+ public <T> List<T> list(List<T> list, Builder<T> builder) {
+ list.add(builder.build());
+ return list;
+ }
+
+ public IpBuilder ipBuilder(String ip, int port) {
+ return new IpBuilder()
+ .setIp(new IpAddress(ip.toCharArray()))
+ .setPort(new PortNumber(port));
+ }
+
+ public DataPlaneLocatorBuilder dataPlaneLocatorBuilder(DataPlaneLocatorBuilder dataPlaneLocatorBuilder,
+ String ip, int port) {
+ return dataPlaneLocatorBuilder
+ .setLocatorType(ipBuilder(ip, port).build())
+ .setTransport(VxlanGpe.class);
+ }
+}
import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.AccessListsBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.AccessList;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.AccessListBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.AccessListEntriesBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.AccessListEntry;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.AccessListEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.access.list.entry.ActionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.access.list.entry.MatchesBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.access.list.entry.actions.packet.handling.PermitBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.access.list.entry.matches.ace.type.AceIpBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.AccessListsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.Acl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.AclBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.AccessListEntriesBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.Ace;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.AceBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.ActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.MatchesBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.actions.packet.handling.PermitBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4Builder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.packet.fields.rev140625.acl.transport.header.fields.DestinationPortRangeBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev150611.acl.transport.header.fields.DestinationPortRangeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.acl.rev150105.RedirectToSfc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.acl.rev150105.RedirectToSfcBuilder;
-public class AclUtils {
- public MatchesBuilder createMatches (MatchesBuilder matchesBuilder, int destPort) {
+public class AclUtils extends AbstractUtils {
+ public MatchesBuilder matchesBuilder(MatchesBuilder matchesBuilder, int destPort) {
PortNumber portNumber = new PortNumber(destPort);
- DestinationPortRangeBuilder destinationPortRangeBuilder = new DestinationPortRangeBuilder();
- destinationPortRangeBuilder.setLowerPort(portNumber);
- destinationPortRangeBuilder.setUpperPort(portNumber);
+ DestinationPortRangeBuilder destinationPortRangeBuilder = new DestinationPortRangeBuilder()
+ .setLowerPort(portNumber)
+ .setUpperPort(portNumber);
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setDestinationPortRange(destinationPortRangeBuilder.build());
- matchesBuilder.setAceType(aceIpBuilder.build());
+ AceIpBuilder aceIpBuilder = new AceIpBuilder()
+ .setDestinationPortRange(destinationPortRangeBuilder.build())
+ .setProtocol((short)6)
+ .setAceIpVersion(new AceIpv4Builder().build());
- return matchesBuilder;
+ return matchesBuilder.setAceType(aceIpBuilder.build());
}
- public ActionsBuilder createActions (ActionsBuilder actionsBuilder, Boolean permit) {
- PermitBuilder permitBuilder = new PermitBuilder();
- permitBuilder.setPermit(Boolean.TRUE);
- actionsBuilder.setPacketHandling(permitBuilder.build());
-
- return actionsBuilder;
+ public ActionsBuilder actionsBuilder(ActionsBuilder actionsBuilder, Boolean permit) {
+ return actionsBuilder.setPacketHandling(new PermitBuilder().setPermit(permit).build());
}
- public AccessListEntryBuilder createAccessListEntryBuilder(AccessListEntryBuilder accessListEntryBuilder,
- String ruleName,
- MatchesBuilder matchesBuilder,
- ActionsBuilder actionsBuilder) {
- accessListEntryBuilder.setRuleName(ruleName);
- accessListEntryBuilder.setMatches(matchesBuilder.build());
- accessListEntryBuilder.setActions(actionsBuilder.build());
+ public ActionsBuilder actionsBuilder(ActionsBuilder actionsBuilder, String sfcName) {
+ RedirectToSfcBuilder redirectToSfcBuilder = new RedirectToSfcBuilder().setSfcName(sfcName);
- return accessListEntryBuilder;
+ return actionsBuilder.addAugmentation(RedirectToSfc.class, redirectToSfcBuilder.build());
}
- public AccessListEntriesBuilder createAccessListEntries(AccessListEntriesBuilder accessListEntriesBuilder,
- AccessListEntryBuilder accessListEntryBuilder) {
- List<AccessListEntry> accessListEntriesList = new ArrayList<>();
- accessListEntriesList.add(accessListEntryBuilder.build());
-
- return accessListEntriesBuilder;
+ public AceBuilder aceBuilder(AceBuilder accessListEntryBuilder,
+ String ruleName,
+ MatchesBuilder matchesBuilder,
+ ActionsBuilder actionsBuilder) {
+ return accessListEntryBuilder
+ .setRuleName(ruleName)
+ .setMatches(matchesBuilder.build())
+ .setActions(actionsBuilder.build());
}
- public AccessListBuilder createAccessList(AccessListBuilder accessListBuilder,
- String aclName,
- AccessListEntriesBuilder accessListEntriesBuilder) {
- accessListBuilder.setAclName(aclName);
- accessListBuilder.setAccessListEntries(accessListEntriesBuilder.build());
+ public AccessListEntriesBuilder accessListEntriesBuidler(AccessListEntriesBuilder accessListEntriesBuilder,
+ AceBuilder aceBuilder) {
+ List<Ace> aceList = new ArrayList<>();
+ aceList.add(aceBuilder.build());
+
+ return accessListEntriesBuilder.setAce(aceList);
+ }
- return accessListBuilder;
+ public AclBuilder aclBuilder(AclBuilder aclBuilder,
+ String aclName,
+ AccessListEntriesBuilder accessListEntriesBuilder) {
+ return aclBuilder
+ .setAclName(aclName)
+ .setAccessListEntries(accessListEntriesBuilder.build());
}
- public AccessListsBuilder createAccessLists(AccessListsBuilder accessListsBuilder,
- AccessListBuilder accessListBuilder) {
- List<AccessList> accessListList = new ArrayList<>();
- accessListList.add(accessListBuilder.build());
- accessListsBuilder.setAccessList(accessListList);
+ public AccessListsBuilder accesslistsbuilder(AccessListsBuilder accessListsBuilder,
+ AclBuilder aclBuilder) {
+ List<Acl> aclList = new ArrayList<>();
+ aclList.add(aclBuilder.build());
- return accessListsBuilder;
+ return accessListsBuilder.setAcl(aclList);
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.Sff;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.SffBuilder;
-public class ClassifierUtils {
- public SffBuilder createSff(SffBuilder sffBuilder, String sffName) {
- sffBuilder.setName(sffName);
-
- return sffBuilder;
+public class ClassifierUtils extends AbstractUtils {
+ public SffBuilder sffBuilder(SffBuilder sffBuilder, String sffName) {
+ return sffBuilder.setName(sffName);
}
- public SffsBuilder createSffs(SffsBuilder sffsBuilder, SffBuilder sffBuilder) {
+ public SffsBuilder sffsBuilder(SffsBuilder sffsBuilder, SffBuilder sffBuilder) {
List<Sff> sffList = new ArrayList<>();
sffList.add(sffBuilder.build());
sffsBuilder.setSff(sffList);
return sffsBuilder;
}
- public ClassifierBuilder createClassifier(ClassifierBuilder classifierBuilder,
- String classifierName, String aclName,
- SffsBuilder sffsBuilder) {
- classifierBuilder.setName(classifierName);
- classifierBuilder.setAcl(aclName);
-
- return classifierBuilder;
+ public ClassifierBuilder classifierBuilder(ClassifierBuilder classifierBuilder,
+ String classifierName, String aclName,
+ SffsBuilder sffsBuilder) {
+ return classifierBuilder
+ .setName(classifierName)
+ .setAcl(aclName);
}
- public ClassifiersBuilder createClassifiers(ClassifiersBuilder classifiersBuilder,
- ClassifierBuilder classifierBuilder) {
+ public ClassifiersBuilder ClassifiersBuilder(ClassifiersBuilder classifiersBuilder,
+ ClassifierBuilder classifierBuilder) {
List<Classifier> classifierList = new ArrayList<>();
classifierList.add(classifierBuilder.build());
classifiersBuilder.setClassifier(classifierList);
--- /dev/null
+/*
+ * Copyright © 2015 Red Hat, 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.ovsdb.openstack.netvirt.sfc.utils;
+
+import java.util.List;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfcName;
+
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.ServiceFunctionChainsBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChain;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChainBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunction;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunctionBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.ServiceFunctionTypeIdentity;
+
+public class ServiceFunctionChainUtils extends AbstractUtils {
+ public SfcServiceFunctionBuilder sfcServiceFunctionBuilder(SfcServiceFunctionBuilder sfcServiceFunctionBuilder,
+ String name,
+ Class<? extends ServiceFunctionTypeIdentity> type) {
+ return sfcServiceFunctionBuilder
+ .setName(name)
+ .setType(type);
+ }
+
+ public ServiceFunctionChainBuilder serviceFunctionChainBuilder(
+ ServiceFunctionChainBuilder serviceFunctionChainBuilder, String name, Boolean symmetric,
+ List<SfcServiceFunction> sfcServiceFunctionList) {
+
+ return serviceFunctionChainBuilder
+ .setName(SfcName.getDefaultInstance(name))
+ .setSymmetric(symmetric)
+ .setSfcServiceFunction(sfcServiceFunctionList);
+ }
+
+ public ServiceFunctionChainsBuilder serviceFunctionChainsBuilder(
+ ServiceFunctionChainsBuilder serviceFunctionChainsBuilder,
+ List<ServiceFunctionChain> serviceFunctionChainBuilderList) {
+
+ return serviceFunctionChainsBuilder.setServiceFunctionChain(serviceFunctionChainBuilderList);
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2015 Red Hat, 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.ovsdb.openstack.netvirt.sfc.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffDataPlaneLocatorName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SnName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.ovs.rev140701.SffOvsBridgeAugmentation;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.ovs.rev140701.SffOvsBridgeAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.ovs.rev140701.SffOvsLocatorOptionsAugmentation;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.ovs.rev140701.SffOvsLocatorOptionsAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.ovs.rev140701.bridge.OvsBridgeBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.ovs.rev140701.options.OvsOptionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwardersBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocator;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.DataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.ServiceFunctionTypeIdentity;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.VxlanGpe;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeName;
+
+public class ServiceFunctionForwarderUtils extends AbstractUtils {
+ public OvsOptionsBuilder ovsOptionsBuilder(OvsOptionsBuilder ovsOptionsBuilder, int port) {
+ String flow = "flow";
+ return ovsOptionsBuilder
+ .setDstPort(String.valueOf(port))
+ .setRemoteIp(flow)
+ .setKey(flow)
+ .setNsi(flow)
+ .setNsp(flow)
+ .setNshc1(flow)
+ .setNshc2(flow)
+ .setNshc3(flow)
+ .setNshc4(flow);
+ }
+
+ public SffDataPlaneLocatorBuilder sffDataPlaneLocatorBuilder(SffDataPlaneLocatorBuilder sffDataPlaneLocatorBuilder,
+ DataPlaneLocatorBuilder dataPlaneLocatorBuilder,
+ String dplName) {
+ SffOvsLocatorOptionsAugmentationBuilder sffOvsLocatorOptionsAugmentationBuilder =
+ new SffOvsLocatorOptionsAugmentationBuilder();
+ sffOvsLocatorOptionsAugmentationBuilder.setOvsOptions(
+ ovsOptionsBuilder(new OvsOptionsBuilder(), 6633).build());
+
+ return sffDataPlaneLocatorBuilder
+ .setName(new SffDataPlaneLocatorName(dplName))
+ .setDataPlaneLocator(dataPlaneLocatorBuilder.build())
+ .addAugmentation(SffOvsLocatorOptionsAugmentation.class,
+ sffOvsLocatorOptionsAugmentationBuilder.build());
+ }
+
+ public SffSfDataPlaneLocatorBuilder sffSfDataPlaneLocatorBuilder(
+ SffSfDataPlaneLocatorBuilder sffSfDataPlaneLocatorBuilder, String ip, int port) {
+ return sffSfDataPlaneLocatorBuilder
+ .setLocatorType(ipBuilder(ip, port).build())
+ .setTransport(VxlanGpe.class);
+ }
+
+ public ServiceFunctionDictionaryBuilder serviceFunctionDictionaryBuilder(
+ ServiceFunctionDictionaryBuilder serviceFunctionDictionaryBuilder,
+ String sfName, Class<? extends ServiceFunctionTypeIdentity> type,
+ SffSfDataPlaneLocatorBuilder sffSfDataPlaneLocatorBuilder) {
+
+ return serviceFunctionDictionaryBuilder
+ .setName(new SfName(sfName))
+ .setType(type)
+ .setSffSfDataPlaneLocator(sffSfDataPlaneLocatorBuilder.build());
+ }
+
+ public OvsBridgeBuilder ovsBridgeBuilder(OvsBridgeBuilder ovsBridgeBuilder, String bridgeNme) {
+ return ovsBridgeBuilder.setBridgeName(bridgeNme);
+ }
+
+ public ServiceFunctionForwarderBuilder serviceFunctionForwarderBuilder(
+ ServiceFunctionForwarderBuilder serviceFunctionForwarderBuilder,
+ String sffName, String serviceNodeName, String bridgeName,
+ List<SffDataPlaneLocator> sffDataPlaneLocatorList,
+ List<ServiceFunctionDictionary> serviceFunctionDictionaryList) {
+
+ SffOvsBridgeAugmentationBuilder sffOvsBridgeAugmentationBuilder = new SffOvsBridgeAugmentationBuilder();
+ sffOvsBridgeAugmentationBuilder.setOvsBridge(ovsBridgeBuilder(new OvsBridgeBuilder(), bridgeName).build());
+
+ return serviceFunctionForwarderBuilder
+ .setName(new SffName(sffName))
+ .setServiceNode(new SnName(serviceNodeName))
+ .setServiceFunctionDictionary(serviceFunctionDictionaryList)
+ .setSffDataPlaneLocator(sffDataPlaneLocatorList)
+ .addAugmentation(SffOvsBridgeAugmentation.class, sffOvsBridgeAugmentationBuilder.build());
+ }
+
+ public ServiceFunctionForwardersBuilder serviceFunctionForwardersBuilder(
+ ServiceFunctionForwardersBuilder serviceFunctionForwardersBuilder,
+ List<ServiceFunctionForwarder> serviceFunctionForwarderList) {
+ return serviceFunctionForwardersBuilder.setServiceFunctionForwarder(serviceFunctionForwarderList);
+ }
+
+ public ServiceFunctionForwarderBuilder serviceFunctionForwarderBuilder(
+ String sffName, String sffIp, int port, String sffDplName,
+ String sfName, String sfIp, String snName, String bridgeName,
+ Class<? extends ServiceFunctionTypeIdentity> type) {
+
+ DataPlaneLocatorBuilder dataPlaneLocatorBuilder =
+ dataPlaneLocatorBuilder(new DataPlaneLocatorBuilder(), sffIp, port);
+ SffDataPlaneLocatorBuilder sffDataPlaneLocatorBuilder =
+ sffDataPlaneLocatorBuilder( new SffDataPlaneLocatorBuilder(), dataPlaneLocatorBuilder, sffDplName);
+ List<SffDataPlaneLocator> sffDataPlaneLocatorList =
+ list(new ArrayList<SffDataPlaneLocator>(), sffDataPlaneLocatorBuilder);
+
+ SffSfDataPlaneLocatorBuilder sffSfDataPlaneLocatorBuilder =
+ sffSfDataPlaneLocatorBuilder(new SffSfDataPlaneLocatorBuilder(), sffIp, port);
+ ServiceFunctionDictionaryBuilder serviceFunctionDictionaryBuilder =
+ serviceFunctionDictionaryBuilder(new ServiceFunctionDictionaryBuilder(), sfName, type,
+ sffSfDataPlaneLocatorBuilder);
+ List<ServiceFunctionDictionary> serviceFunctionDictionaryList =
+ list(new ArrayList<ServiceFunctionDictionary>(), serviceFunctionDictionaryBuilder);
+
+ ServiceFunctionForwarderBuilder serviceFunctionForwarderBuilder =
+ serviceFunctionForwarderBuilder(
+ new ServiceFunctionForwarderBuilder(), sffName, snName, bridgeName,
+ sffDataPlaneLocatorList, serviceFunctionDictionaryList);
+ return serviceFunctionForwarderBuilder;
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2015 Red Hat, 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.ovsdb.openstack.netvirt.sfc.utils;
+
+import java.util.List;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfcName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfpName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPathsBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathBuilder;
+
+public class ServiceFunctionPathUtils extends AbstractUtils {
+ public ServiceFunctionPathBuilder serviceFunctionPathBuilder(
+ ServiceFunctionPathBuilder serviceFunctionPathBuilder,
+ String sfpName, String sfcName, short startingIndex, Boolean symmetric) {
+
+ return serviceFunctionPathBuilder
+ .setSymmetric(symmetric)
+ .setName(SfpName.getDefaultInstance(sfpName))
+ .setServiceChainName(SfcName.getDefaultInstance(sfcName))
+ .setStartingIndex(startingIndex);
+ }
+
+ public ServiceFunctionPathsBuilder serviceFunctionPathsBuilder(
+ List<ServiceFunctionPath> serviceFunctionPathList) {
+
+ return new ServiceFunctionPathsBuilder().setServiceFunctionPath(serviceFunctionPathList);
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2015 Red Hat, 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.ovsdb.openstack.netvirt.sfc.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfDataPlaneLocatorName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.entry.SfDataPlaneLocator;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.entry.SfDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunctionBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Firewall;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.ServiceFunctionTypeIdentity;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.VxlanGpe;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+
+public class ServiceFunctionUtils extends AbstractUtils {
+ public SfDataPlaneLocatorBuilder sfDataPlaneLocatorBuilder(SfDataPlaneLocatorBuilder sfDataPlaneLocatorBuilder,
+ String ip, int port, String dplName, String sffName) {
+ return sfDataPlaneLocatorBuilder
+ .setLocatorType(ipBuilder(ip, port).build())
+ .setName(new SfDataPlaneLocatorName(dplName))
+ .setTransport(VxlanGpe.class)
+ .setServiceFunctionForwarder(new SffName(sffName));
+ }
+
+ public ServiceFunctionBuilder serviceFunctionBuilder(ServiceFunctionBuilder serviceFunctionBuilder,
+ String ip, String sfName,
+ List<SfDataPlaneLocator> sfDataPlaneLocatorList,
+ Class<? extends ServiceFunctionTypeIdentity> type) {
+ return serviceFunctionBuilder
+ .setSfDataPlaneLocator(sfDataPlaneLocatorList)
+ .setName(new SfName(sfName))
+ .setIpMgmtAddress(new IpAddress(ip.toCharArray()))
+ .setType(type)
+ .setNshAware(true);
+ }
+
+ public ServiceFunctionsBuilder serviceFunctionsBuilder(ServiceFunctionsBuilder serviceFunctionsBuilder,
+ List<ServiceFunction> serviceFunctionList) {
+ return serviceFunctionsBuilder.setServiceFunction(serviceFunctionList);
+ }
+
+ public ServiceFunctionBuilder serviceFunctionBuilder(String sfIp, int port, String sf1DplName,
+ String sffname, String sfName) {
+ SfDataPlaneLocatorBuilder sfDataPlaneLocator =
+ sfDataPlaneLocatorBuilder(new SfDataPlaneLocatorBuilder(), sfIp, port, sf1DplName, sffname);
+ List<SfDataPlaneLocator> sfDataPlaneLocatorList =
+ list(new ArrayList<SfDataPlaneLocator>(), sfDataPlaneLocator);
+ return serviceFunctionBuilder(
+ new ServiceFunctionBuilder(), sfIp, sfName, sfDataPlaneLocatorList, Firewall.class);
+ }
+
+
+}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.rev150105.SfcBuilder;
public class SfcUtils {
- public SfcBuilder createSfc(SfcBuilder sfcBuilder, String sfcName) {
- sfcBuilder.setName(sfcName);
-
- return sfcBuilder;
+ public SfcBuilder sfcBuilder(SfcBuilder sfcBuilder, String sfcName) {
+ return sfcBuilder.setName(sfcName);
}
}
<artifactId>utils.servicehelper</artifactId>
<version>${ovsdb.utils.servicehelper.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>utils.mdsal-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-common</artifactId>
import org.apache.commons.lang3.tuple.Pair;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.ovsdb.openstack.netvirt.translator.*;
+import org.opendaylight.ovsdb.openstack.netvirt.api.ArpProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.BridgeConfigurationManager;
+import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
+import org.opendaylight.ovsdb.openstack.netvirt.api.EgressAclProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
+import org.opendaylight.ovsdb.openstack.netvirt.api.GatewayMacResolver;
+import org.opendaylight.ovsdb.openstack.netvirt.api.InboundNatProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.IngressAclProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.L3ForwardingProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.LoadBalancerProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.MultiTenantAwareRouter;
+import org.opendaylight.ovsdb.openstack.netvirt.api.NetworkingProviderManager;
+import org.opendaylight.ovsdb.openstack.netvirt.api.NodeCacheListener;
+import org.opendaylight.ovsdb.openstack.netvirt.api.NodeCacheManager;
+import org.opendaylight.ovsdb.openstack.netvirt.api.OutboundNatProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbInventoryListener;
+import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbInventoryService;
+import org.opendaylight.ovsdb.openstack.netvirt.api.RoutingProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityGroupCacheManger;
+import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
+import org.opendaylight.ovsdb.openstack.netvirt.api.TenantNetworkManager;
+import org.opendaylight.ovsdb.openstack.netvirt.api.VlanConfigurationCache;
+import org.opendaylight.ovsdb.openstack.netvirt.impl.BridgeConfigurationManagerImpl;
+import org.opendaylight.ovsdb.openstack.netvirt.impl.ConfigurationServiceImpl;
+import org.opendaylight.ovsdb.openstack.netvirt.impl.EventDispatcherImpl;
+import org.opendaylight.ovsdb.openstack.netvirt.impl.NeutronL3Adapter;
+import org.opendaylight.ovsdb.openstack.netvirt.impl.NodeCacheManagerImpl;
+import org.opendaylight.ovsdb.openstack.netvirt.impl.OpenstackRouter;
+import org.opendaylight.ovsdb.openstack.netvirt.impl.OvsdbInventoryServiceImpl;
+import org.opendaylight.ovsdb.openstack.netvirt.impl.ProviderNetworkManagerImpl;
+import org.opendaylight.ovsdb.openstack.netvirt.impl.SecurityGroupCacheManagerImpl;
+import org.opendaylight.ovsdb.openstack.netvirt.impl.SecurityServicesImpl;
+import org.opendaylight.ovsdb.openstack.netvirt.impl.SouthboundImpl;
+import org.opendaylight.ovsdb.openstack.netvirt.impl.TenantNetworkManagerImpl;
+import org.opendaylight.ovsdb.openstack.netvirt.impl.VlanConfigurationCacheImpl;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronFloatingIPCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerPoolCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronSecurityGroupAware;
import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronSecurityRuleAware;
import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronSubnetAware;
-import org.opendaylight.ovsdb.openstack.netvirt.api.*;
-import org.opendaylight.ovsdb.openstack.netvirt.impl.*;
+import org.opendaylight.ovsdb.utils.mdsal.utils.NeutronModelsDataStoreHelper;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
public class ConfigActivator implements BundleActivator {
private static final Logger LOG = LoggerFactory.getLogger(ConfigActivator.class);
- private List<ServiceRegistration<?>> translatorCRUDRegistrations = new ArrayList<ServiceRegistration<?>>();
+ private List<ServiceRegistration<?>> translatorCRUDRegistrations = new ArrayList<>();
private List<Pair<Object, ServiceRegistration>> servicesAndRegistrations = new ArrayList<>();
private ProviderContext providerContext;
registerService(context,
new String[]{SecurityServicesManager.class.getName()}, null, securityServices);
+ final SecurityGroupCacheManger securityGroupCacheManger = new SecurityGroupCacheManagerImpl();
+ registerService(context,
+ new String[]{SecurityGroupCacheManger.class.getName()}, null, securityGroupCacheManger);
+
+ registerService(context,
+ new String[]{SecurityServicesManager.class.getName()}, null, securityServices);
+
FWaasHandler fWaasHandler = new FWaasHandler();
registerAbstractHandlerService(context,
new Class[] {INeutronFirewallAware.class, INeutronFirewallRuleAware.class, INeutronFirewallPolicyAware.class},
registerService(context,
new String[]{EventDispatcher.class.getName()}, null, eventDispatcher);
- final NeutronL3Adapter neutronL3Adapter = new NeutronL3Adapter();
+ final NeutronL3Adapter neutronL3Adapter = new NeutronL3Adapter(
+ new NeutronModelsDataStoreHelper(this.providerContext.getSALService(DataBroker.class)));
registerService(context,
new String[]{NeutronL3Adapter.class.getName()}, null, neutronL3Adapter);
securityServices, neutronL3Adapter);
trackService(context, INeutronPortCRUD.class, tenantNetworkManager, lBaaSHandler, lBaaSPoolHandler,
lBaaSPoolMemberHandler, securityServices, neutronL3Adapter);
+ trackService(context, INeutronFloatingIPCRUD.class, neutronL3Adapter);
trackService(context, INeutronLoadBalancerCRUD.class, lBaaSHandler, lBaaSPoolHandler, lBaaSPoolMemberHandler);
trackService(context, INeutronLoadBalancerPoolCRUD.class, lBaaSHandler, lBaaSPoolMemberHandler);
trackService(context, LoadBalancerProvider.class, lBaaSHandler, lBaaSPoolHandler, lBaaSPoolMemberHandler);
@Override
public void stop(BundleContext context) throws Exception {
- LOG.info("Stop Translator CRUD service provides");
+ LOG.info("ConfigActivator stop");
// ServiceTrackers and services are already released when bundle stops,
// so we don't need to close the trackers or unregister the services
- for (ServiceRegistration registration : translatorCRUDRegistrations) {
- if (registration != null) {
- registration.unregister();
- }
- }
-
}
private ServiceRegistration<?> registerService(BundleContext bundleContext, String[] interfaces,
public static final String OVSDB_URI_PREFIX = "ovsdb";
public static final String BRIDGE_URI_PREFIX = "bridge";
public static final String TP_URI_PREFIX = "termination-point";
+ public static final String DISABLE_IN_BAND = "disable-in-band";
public static final ImmutableBiMap<Class<? extends OvsdbBridgeProtocolBase>,String> OVSDB_PROTOCOL_MAP
= new ImmutableBiMap.Builder<Class<? extends OvsdbBridgeProtocolBase>,String>()
@Override
public void close() throws Exception {
+ LOG.info("NetvirtProvider closed");
activator.stop(bundleContext);
}
import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
import java.util.AbstractMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
return null;
}
- List<Neutron_IPs> fixedIPs;
- Iterator<Neutron_IPs> fixedIPIterator;
- Neutron_IPs ip;
-
List<NeutronPort> allPorts = neutronPortsCache.getAllPorts();
- Iterator<NeutronPort> i = allPorts.iterator();
- while (i.hasNext()) {
- NeutronPort port = i.next();
- fixedIPs = port.getFixedIPs();
- if (fixedIPs != null && fixedIPs.size() > 0) {
- fixedIPIterator = fixedIPs.iterator();
- while (fixedIPIterator.hasNext()) {
- ip = fixedIPIterator.next();
+ for (NeutronPort port : allPorts) {
+ List<Neutron_IPs> fixedIPs = port.getFixedIPs();
+ if (fixedIPs != null && !fixedIPs.isEmpty()) {
+ for (Neutron_IPs ip : fixedIPs) {
if (ip.getIpAddress().equals(ipAddr) && ip.getSubnetUUID().equals(subnetID)) {
return port.getMacAddress();
}
List<NeutronNetwork> allNetworks = neutronNetworkCache.getAllNetworks();
for (NeutronNetwork network: allNetworks) {
if (network.getID().equals(networkID)) {
- Map.Entry<String,String> entry = new AbstractMap.SimpleEntry<String, String>(
+ return new AbstractMap.SimpleEntry<>(
network.getProviderNetworkType(), network.getProviderSegmentationID());
- return entry;
}
}
return null;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter_Interface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnet;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
private NeutronLoadBalancer loadBalancer;
private NeutronLoadBalancerPool loadBalancerPool;
private NeutronLoadBalancerPoolMember loadBalancerPoolMember;
+ private NeutronSecurityRule neutronSecurityRule;
NorthboundEvent(NeutronPort port, Action action) {
super(HandlerType.NEUTRON_PORT, action);
this.loadBalancerPoolMember = loadBalancerPoolMember;
}
+ NorthboundEvent(NeutronSecurityRule neutronSecurityRule, Action action) {
+ super(HandlerType.NEUTRON_PORT_SECURITY, action);
+ this.neutronSecurityRule = neutronSecurityRule;
+ }
+
public NeutronPort getPort() {
return port;
}
public NeutronLoadBalancerPoolMember getLoadBalancerPoolMember() {
return loadBalancerPoolMember;
}
+ public NeutronSecurityRule getNeutronSecurityRule() {
+ return neutronSecurityRule;
+ }
@Override
public String toString() {
+ ", loadBalancer=" + loadBalancer
+ ", loadBalancerPool=" + loadBalancerPool
+ ", loadBalancerPoolMember=" + loadBalancerPoolMember
+ + ", neutronsecurityRule=" + neutronSecurityRule
+ "]";
}
result = prime * result + ((routerInterface == null) ? 0 : routerInterface.hashCode());
result = prime * result + ((neutronFloatingIP == null) ? 0 : neutronFloatingIP.hashCode());
result = prime * result + ((neutronNetwork == null) ? 0 : neutronNetwork.hashCode());
+ result = prime * result + ((neutronSecurityRule == null) ? 0 : neutronSecurityRule.hashCode());
return result;
}
} else if (!loadBalancerPoolMember.equals(other.loadBalancerPoolMember)) {
return false;
}
+ if (neutronSecurityRule == null) {
+ if (other.neutronSecurityRule != null) {
+ return false;
+ }
+ } else if (!neutronSecurityRule.equals(other.neutronSecurityRule)) {
+ return false;
+ }
return true;
}
}
package org.opendaylight.ovsdb.openstack.netvirt;
import java.net.HttpURLConnection;
+import java.util.ArrayList;
+import java.util.List;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronSecurityGroupAware;
import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronSecurityRuleAware;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
+import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
implements INeutronSecurityGroupAware, INeutronSecurityRuleAware, ConfigInterface {
private static final Logger LOG = LoggerFactory.getLogger(PortSecurityHandler.class);
+ private volatile INeutronPortCRUD neutronPortCache;
+ private volatile SecurityServicesManager securityServicesManager;
@Override
public int canCreateNeutronSecurityGroup(NeutronSecurityGroup neutronSecurityGroup) {
@Override
public void neutronSecurityRuleCreated(NeutronSecurityRule neutronSecurityRule) {
- int result = canCreateNeutronSecurityRule(neutronSecurityRule);
- if (result != HttpURLConnection.HTTP_CREATED) {
- LOG.debug("Neutron Security Group creation failed {} ", result);
- }
+ enqueueEvent(new NorthboundEvent(neutronSecurityRule, Action.ADD));
}
@Override
@Override
public void neutronSecurityRuleDeleted(NeutronSecurityRule neutronSecurityRule) {
- int result = canDeleteNeutronSecurityRule(neutronSecurityRule);
- if (result != HttpURLConnection.HTTP_OK) {
- LOG.error(" delete Neutron Security Rule validation failed for result - {} ", result);
- }
+ enqueueEvent(new NorthboundEvent(neutronSecurityRule, Action.DELETE));
}
/**
}
NorthboundEvent ev = (NorthboundEvent) abstractEvent;
switch (ev.getAction()) {
- // TODO: add handling of events here, once callbacks do something
- // other than logging.
+ case ADD:
+ processNeutronSecurityRuleAdded(ev.getNeutronSecurityRule());
+ break;
+ case DELETE:
+ processNeutronSecurityRuleDeleted(ev.getNeutronSecurityRule());
+ break;
default:
LOG.warn("Unable to process event action {}", ev.getAction());
break;
}
}
+ private void processNeutronSecurityRuleAdded(NeutronSecurityRule neutronSecurityRule) {
+ List<NeutronPort> portList = getPortWithSecurityGroup(neutronSecurityRule.getSecurityRuleGroupID());
+ for (NeutronPort port:portList) {
+ syncSecurityGroup(neutronSecurityRule,port,neutronSecurityRule.getSecurityRuleGroupID(),true);
+ }
+ }
+
+ private void processNeutronSecurityRuleDeleted(NeutronSecurityRule neutronSecurityRule) {
+ List<NeutronPort> portList = getPortWithSecurityGroup(neutronSecurityRule.getSecurityRuleGroupID());
+ for (NeutronPort port:portList) {
+ syncSecurityGroup(neutronSecurityRule,port,neutronSecurityRule.getSecurityRuleGroupID(),false);
+ }
+ }
+
+ private void syncSecurityGroup(NeutronSecurityRule securityRule,NeutronPort port,
+ String neutronSecurityGroupId,boolean write) {
+
+ if (null != securityRule.getSecurityRemoteGroupID()) {
+ List<Neutron_IPs> vmIpList = securityServicesManager
+ .getVmListForSecurityGroup(port.getID(), neutronSecurityGroupId);
+ for (Neutron_IPs vmIp :vmIpList ) {
+ securityServicesManager.syncSecurityRule(port, securityRule, vmIp, write);
+ }
+ } else {
+ securityServicesManager.syncSecurityRule(port, securityRule, null, write);
+ }
+ }
+
+ private List<NeutronPort> getPortWithSecurityGroup(String securityGroupUuid) {
+
+ List<NeutronPort> neutronPortList = neutronPortCache.getAllPorts();
+ List<NeutronPort> neutronPortInSG = new ArrayList<NeutronPort>();
+ for (NeutronPort neutronPort:neutronPortList) {
+ List<NeutronSecurityGroup> securityGroupList = neutronPort.getSecurityGroups();
+ for (NeutronSecurityGroup neutronSecurityGroup:securityGroupList) {
+ if (neutronSecurityGroup.getID().equals(securityGroupUuid)) {
+ neutronPortInSG.add(neutronPort);
+ break;
+ }
+ }
+ }
+ return neutronPortInSG;
+ }
+
@Override
public void setDependencies(ServiceReference serviceReference) {
eventDispatcher =
(EventDispatcher) ServiceHelper.getGlobalInstance(EventDispatcher.class, this);
eventDispatcher.eventHandlerAdded(serviceReference, this);
+ neutronPortCache =
+ (INeutronPortCRUD) ServiceHelper.getGlobalInstance(INeutronPortCRUD.class, this);
+ securityServicesManager =
+ (SecurityServicesManager) ServiceHelper.getGlobalInstance(SecurityServicesManager.class, this);
}
@Override
package org.opendaylight.ovsdb.openstack.netvirt.api;
-import java.util.List;
-
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import java.util.List;
+
/**
* This interface allows egress Port Security flows to be written to devices.
*/
public interface EgressAclProvider {
/**
- * Program port security ACL.
+ * Program port security Group.
*
* @param dpid the dpid
* @param segmentationId the segmentation id
* @param attachedMac the attached mac
* @param localPort the local port
* @param securityGroup the security group
- * @param srcAddressList the src address associated with the vm port
+ * @param portUuid the uuid of the port.
* @param write is this flow write or delete
*/
- void programPortSecurityAcl(Long dpid, String segmentationId, String attachedMac,
+ void programPortSecurityGroup(Long dpid, String segmentationId, String attachedMac,
long localPort, NeutronSecurityGroup securityGroup,
- List<Neutron_IPs> srcAddressList, boolean write);
+ String portUuid, boolean write);
+ /**
+ * Program port security rule.
+ *
+ * @param dpid the dpid
+ * @param segmentationId the segmentation id
+ * @param attachedMac the attached mac
+ * @param localPort the local port
+ * @param portSecurityRule the security rule
+ * @param vmIp the ip of the remote vm if it has a remote security group.
+ * @param write is this flow write or delete
+ */
+ public void programPortSecurityRule(Long dpid, String segmentationId, String attachedMac,
+ long localPort, NeutronSecurityRule portSecurityRule,
+ Neutron_IPs vmIp, boolean write) ;
/**
- * Program fixed egress ACL rules that will be associated with the VM port when a vm is spawned.
+ * Program fixed egress security group rules that will be associated with the VM port when a vm is spawned.
*
* @param dpid the dpid
* @param segmentationId the segmentation id
* @param isComputePort indicates whether this port is a compute port or not
* @param write is this flow writing or deleting
*/
- void programFixedSecurityAcl(Long dpid, String segmentationId,String attachedMac, long localPort,
+ void programFixedSecurityGroup(Long dpid, String segmentationId,String attachedMac, long localPort,
List<Neutron_IPs> srcAddressList, boolean isLastPortinBridge,
boolean isComputePort, boolean write);
}
\ No newline at end of file
package org.opendaylight.ovsdb.openstack.netvirt.api;
-import java.util.List;
-
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
/**
public interface IngressAclProvider {
/**
- * Program port security ACL.
+ * Program port security Group.
*
* @param dpid the dpid
* @param segmentationId the segmentation id
* @param attachedMac the attached mac
* @param localPort the local port
* @param securityGroup the security group
- * @param srcAddressList the src address associated with the vm port
+ * @param portUuid the uuid of the port.
* @param write is this flow write or delete
*/
- void programPortSecurityAcl(Long dpid, String segmentationId, String attachedMac,
+ void programPortSecurityGroup(Long dpid, String segmentationId, String attachedMac,
long localPort, NeutronSecurityGroup securityGroup,
- List<Neutron_IPs> srcAddressList, boolean write);
+ String portUuid, boolean write);
+ /**
+ * Program port security rule.
+ *
+ * @param dpid the dpid
+ * @param segmentationId the segmentation id
+ * @param attachedMac the attached mac
+ * @param localPort the local port
+ * @param portSecurityRule the security rule
+ * @param vmIp the ip of the remote vm if it has a remote security group.
+ * @param write is this flow write or delete
+ */
+ void programPortSecurityRule(Long dpid, String segmentationId, String attachedMac,
+ long localPort, NeutronSecurityRule portSecurityRule,
+ Neutron_IPs vmIp, boolean write);
/**
* Program fixed ingress ACL rules that will be associated with the VM port when a vm is spawned.
* *
* @param isComputePort indicates whether this port is a compute port or not
* @param write is this flow writing or deleting
*/
- void programFixedSecurityAcl(Long dpid, String segmentationId, String attachedMac, long localPort,
+ void programFixedSecurityGroup(Long dpid, String segmentationId, String attachedMac, long localPort,
boolean isLastPortinSubnet, boolean isComputePort, boolean write);
}
\ No newline at end of file
*/
int index = 0;
for(Map.Entry<String, LoadBalancerPoolMember> entry : this.getMembers().entrySet()) {
- ((LoadBalancerPoolMember) entry.getValue()).setIndex(index++);
+ entry.getValue().setIndex(index++);
}
return this.members;
}
--- /dev/null
+/*
+ * Copyright (c) 2014, 2015 HP, 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.ovsdb.openstack.netvirt.api;
+
+/**
+ * This interface maintain a mapping between the security group and the ports
+ * have this security group as a remote security group. Whenever a new port is
+ * added with a security group associated with it, a rule will be added to allow
+ * traffic from/to the vm from the vms which has the former as a remote sg in its rule.
+ *
+ * @author Aswin Suryanarayanan.
+ */
+
+public interface SecurityGroupCacheManger {
+
+ /**
+ * Notifies that a new port in the security group with securityGroupUuid.
+ * @param securityGroupUuid the uuid of the security group associated with the port.
+ * @param portUuid the uuid of the port.
+ */
+ void portAdded(String securityGroupUuid, String portUuid);
+ /**
+ * Notifies that a port is removed with the securityGroupUuid.
+ * @param securityGroupUuid the uuid of the security group associated with the port.
+ * @param portUuid the uuid of the port.
+ */
+ void portRemoved(String securityGroupUuid, String portUuid);
+ /**
+ * A port with portUuid has a reference remote security group remoteSgUuid will be added
+ * to the cache maintained.
+ * @param remoteSgUuid the remote security group uuid.
+ * @param portUuid the uuid of the port.
+ */
+ void addToCache(String remoteSgUuid, String portUuid);
+ /**A port with portUUID has a reference remote security group remoteSgUuid will be removed
+ * from the cache maintained.
+ * @param remoteSgUuid the remote security group uuid.
+ * @param portUuid portUUID the uuid of the port.
+ */
+ void removeFromCache(String remoteSgUuid, String portUuid);
+}
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
List<Neutron_IPs> getIpAddressList(Node node, OvsdbTerminationPointAugmentation intf);
/**
* Get the list of vm belonging to a security group.
- * @param srcAddressList the address list of the connected vm.
+ * @param portUuid the uuid of the port.
* @param securityGroupUuid the UUID of the remote security group.
* @return the list of all vm belonging to the security group UUID passed.
*/
- List<Neutron_IPs> getVmListForSecurityGroup(List<Neutron_IPs> srcAddressList,
+ List<Neutron_IPs> getVmListForSecurityGroup(String portUuid,
String securityGroupUuid);
/**
- * Add or remove the security groups rules from the port.
+ * Add or remove the security groups from the port.
* @param port the neutron port.
* @param securityGroup the security group associated with the port.
* @param write whether to add/delete flow.
*/
void syncSecurityGroup(NeutronPort port, List<NeutronSecurityGroup> securityGroup, boolean write);
-}
+ /**
+ * Add or remove individual security rules from the port.
+ * @param port the neutron port.
+ * @param securityRule the security group associated with the port.
+ * @param vmIp The list of remote vm ips.
+ * @param write whether to add/delete flow.
+ */
+ void syncSecurityRule(NeutronPort port, NeutronSecurityRule securityRule,Neutron_IPs vmIp, boolean write);
+}
\ No newline at end of file
OvsdbNodeAugmentation extractOvsdbNode(Node node);
NodeId extractBridgeOvsdbNodeId(Node bridgeNode);
List<Node> readOvsdbTopologyNodes();
+ List<Node> readOvsdbTopologyBridgeNodes();
Node readOvsdbNode(Node bridgeNode);
boolean isBridgeOnOvsdbNode(Node node, String bridgeName);
String getOvsdbNodeUUID(Node node);
public <D extends org.opendaylight.yangtools.yang.binding.DataObject> boolean delete(
final LogicalDatastoreType store, final InstanceIdentifier<D> path) {
boolean result = false;
- final WriteTransaction transaction = databroker.newWriteOnlyTransaction();
- transaction.delete(store, path);
- CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
- try {
- future.checkedGet();
+ if(this.read(store,path) != null) {
+ final WriteTransaction transaction = databroker.newWriteOnlyTransaction();
+ transaction.delete(store, path);
+ CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
+ try {
+ future.checkedGet();
+ result = true;
+ } catch (TransactionCommitFailedException e) {
+ LOG.warn("Failed to delete {} ", path, e);
+ }
+ } else {
result = true;
- } catch (TransactionCommitFailedException e) {
- LOG.warn("Failed to delete {} ", path, e);
}
return result;
}
package org.opendaylight.ovsdb.openstack.netvirt.impl;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
+import org.opendaylight.ovsdb.openstack.netvirt.ConfigInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
+import org.opendaylight.ovsdb.openstack.netvirt.api.ArpProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
+import org.opendaylight.ovsdb.openstack.netvirt.api.GatewayMacResolver;
+import org.opendaylight.ovsdb.openstack.netvirt.api.InboundNatProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.L3ForwardingProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.NodeCacheManager;
+import org.opendaylight.ovsdb.openstack.netvirt.api.OutboundNatProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.RoutingProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Status;
+import org.opendaylight.ovsdb.openstack.netvirt.api.StatusCode;
+import org.opendaylight.ovsdb.openstack.netvirt.api.TenantNetworkManager;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFloatingIP;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnet;
import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronFloatingIPCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
-import org.opendaylight.ovsdb.openstack.netvirt.ConfigInterface;
-import org.opendaylight.ovsdb.openstack.netvirt.api.*;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl.NeutronIAwareUtil;
+import org.opendaylight.ovsdb.utils.mdsal.utils.NeutronModelsDataStoreHelper;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
/**
* Neutron L3 Adapter implements a hub-like adapter for the various Neutron events. Based on
* these events, the abstract router callbacks can be generated to the multi-tenant aware router,
private volatile INeutronNetworkCRUD neutronNetworkCache;
private volatile INeutronSubnetCRUD neutronSubnetCache;
private volatile INeutronPortCRUD neutronPortCache;
+ private volatile INeutronFloatingIPCRUD neutronFloatingIpCache;
private volatile L3ForwardingProvider l3ForwardingProvider;
private volatile InboundNatProvider inboundNatProvider;
private volatile OutboundNatProvider outboundNatProvider;
}
}
- private Set<String> inboundIpRewriteCache;
- private Set<String> outboundIpRewriteCache;
- private Set<String> outboundIpRewriteExclusionCache;
- private Set<String> routerInterfacesCache;
- private Set<String> staticArpEntryCache;
- private Set<String> l3ForwardingCache;
private Map<String, String> networkIdToRouterMacCache;
private Map<String, List<Neutron_IPs>> networkIdToRouterIpListCache;
private Map<String, NeutronRouter_Interface> subnetIdToRouterInterfaceCache;
+
private Map<String, Pair<Long, Uuid>> neutronPortToDpIdCache;
private Map<String, FloatIpData> floatIpDataMapCache;
+
private String externalRouterMac;
private Boolean enabled = false;
private Boolean flgDistributedARPEnabled = true;
- private Southbound southbound;
+ private Boolean isCachePopulationDone = false;
private final ExecutorService gatewayMacResolverPool = Executors.newFixedThreadPool(5);
+ private Southbound southbound;
+ private NeutronModelsDataStoreHelper neutronModelsDataStoreHelper;
+
private static final String OWNER_ROUTER_INTERFACE = "network:router_interface";
private static final String OWNER_ROUTER_INTERFACE_DISTRIBUTED = "network:router_interface_distributed";
private static final String OWNER_ROUTER_GATEWAY = "network:router_gateway";
private static final String OWNER_FLOATING_IP = "network:floatingip";
private static final String DEFAULT_EXT_RTR_MAC = "00:00:5E:00:01:01";
- public NeutronL3Adapter() {
+ public NeutronL3Adapter(NeutronModelsDataStoreHelper neutronHelper) {
LOG.info(">>>>>> NeutronL3Adapter constructor {}", this.getClass());
+ this.neutronModelsDataStoreHelper = neutronHelper;
}
private void initL3AdapterMembers() {
Preconditions.checkNotNull(configurationService);
if (configurationService.isL3ForwardingEnabled()) {
- this.inboundIpRewriteCache = new HashSet<>();
- this.outboundIpRewriteCache = new HashSet<>();
- this.outboundIpRewriteExclusionCache = new HashSet<>();
- this.routerInterfacesCache = new HashSet<>();
- this.staticArpEntryCache = new HashSet<>();
- this.l3ForwardingCache = new HashSet<>();
this.networkIdToRouterMacCache = new HashMap<>();
this.networkIdToRouterIpListCache = new HashMap<>();
this.subnetIdToRouterInterfaceCache = new HashMap<>();
}
}
- //
- // Callbacks from OVSDB's northbound handlers
- //
+ private void populateL3ForwardingCaches() {
+ if (!this.enabled) {
+ return;
+ }
+ if(this.isCachePopulationDone || this.neutronFloatingIpCache == null
+ || this.neutronPortCache == null ||this.neutronNetworkCache == null) {
+ return;
+ }
+ this.isCachePopulationDone = true;
+ LOG.debug("Populating NetVirt L3 caches from data store configuration");
+ Routers routers = this.neutronModelsDataStoreHelper.readAllNeutronRouters();
+ Ports ports = this.neutronModelsDataStoreHelper.readAllNeutronPorts();
+ if(routers != null && routers.getRouter() != null && ports != null) {
+ LOG.debug("L3 Cache Population : {} Neutron router present in data store",routers.getRouter().size());
+ for( Router router : routers.getRouter()) {
+ LOG.debug("L3 Cache Population : Populate caches for router {}",router);
+ if(!ports.getPort().isEmpty()) {
+ for( Port port : ports.getPort()) {
+ if (port.getDeviceId().equals(router.getUuid().getValue()) &&
+ port.getDeviceOwner().equals(OWNER_ROUTER_INTERFACE)) {
+ LOG.debug("L3 Cache Population : Router interface {} found.",port);
+ networkIdToRouterMacCache.put(port.getNetworkId().getValue()
+ , port.getMacAddress());
+
+ networkIdToRouterIpListCache.put(port.getNetworkId().getValue(),
+ NeutronIAwareUtil.convertMDSalIpToNeutronIp(port.getFixedIps()));
+ subnetIdToRouterInterfaceCache.put(port.getFixedIps().get(0).getSubnetId().getValue(),
+ NeutronIAwareUtil.convertMDSalInterfaceToNeutronRouterInterface(port));
+ }
+ }
+ }else {
+ LOG.warn("L3 Cache Population :Did not find any port information " +
+ "in config Data Store for router {}",router);
+ }
+ }
+ }
+ LOG.debug("NetVirt L3 caches population is done");
+ }
+
+ private Pair<Long, Uuid> getDpIdOfNeutronPort(String neutronTenantPortUuid) {
+ if(neutronPortToDpIdCache.get(neutronTenantPortUuid) == null) {
+ List<Node> bridges = this.southbound.readOvsdbTopologyBridgeNodes();
+ LOG.debug("getDpIdOfNeutronPort : {} bridges present in ovsdb topology",bridges.size());
+ for(Node bridge : bridges) {
+ List<OvsdbTerminationPointAugmentation> interfaces
+ = southbound.extractTerminationPointAugmentations(bridge);
+ if(interfaces != null && !interfaces.isEmpty()) {
+ LOG.debug("getDpIdOfNeutronPort : {} termination point present on bridge {}",
+ interfaces.size(), bridge.getNodeId());
+ for (OvsdbTerminationPointAugmentation intf : interfaces) {
+ NeutronPort neutronPort = tenantNetworkManager.getTenantPort(intf);
+ if(neutronPort != null && neutronPort.getID().equals(neutronTenantPortUuid)) {
+ Long dpId = getDpidForIntegrationBridge(bridge);
+ Uuid interfaceUuid = intf.getInterfaceUuid();
+ LOG.debug("getDpIdOfNeutronPort : Found bridge {} and interface {} for the tenant neutron" +
+ " port {}",dpId,interfaceUuid,neutronTenantPortUuid);
+ handleInterfaceEventAdd(neutronPort.getPortUUID(), dpId, interfaceUuid);
+ break;
+ }
+ }
+ }
+ }
+ }
+ return neutronPortToDpIdCache.get(neutronTenantPortUuid);
+ }
+
+ private Collection<FloatIpData> getAllFloatingIPsWithMetadata() {
+ LOG.debug("getAllFloatingIPsWithMetadata : Fechting all floating Ips and it's metadata");
+ List<NeutronFloatingIP> neutronFloatingIps = neutronFloatingIpCache.getAllFloatingIPs();
+ if(neutronFloatingIps != null && !neutronFloatingIps.isEmpty()) {
+ for (NeutronFloatingIP neutronFloatingIP : neutronFloatingIps) {
+ if(!floatIpDataMapCache.containsKey(neutronFloatingIP.getID())){
+ LOG.debug("Metadata for floating ip {} is not present in the cache. " +
+ "Fetching from data store.",neutronFloatingIP.getID());
+ this.getFloatingIPWithMetadata(neutronFloatingIP.getID());
+ }
+ }
+ }
+ LOG.debug("getAllFloatingIPsWithMetadata : {} floating points found in data store",floatIpDataMapCache.size());
+ return floatIpDataMapCache.values();
+ }
+ private FloatIpData getFloatingIPWithMetadata(String neutronFloatingId) {
+ LOG.debug("getFloatingIPWithMetadata : Get Floating ip and it's meta data for neutron " +
+ "floating id {} ",neutronFloatingId);
+ if(floatIpDataMapCache.get(neutronFloatingId) == null) {
+ NeutronFloatingIP neutronFloatingIP = neutronFloatingIpCache.getFloatingIP(neutronFloatingId);
+ if (neutronFloatingIP == null) {
+ LOG.error("getFloatingIPWithMetadata : Floating ip {} is missing from data store, that should not happen",neutronFloatingId);
+ return null;
+ }
+ List<NeutronPort> neutronPorts = neutronPortCache.getAllPorts();
+ NeutronPort neutronPortForFloatIp = null;
+ for (NeutronPort neutronPort : neutronPorts) {
+ if (neutronPort.getDeviceOwner().equals(OWNER_FLOATING_IP) &&
+ neutronPort.getDeviceID().equals(neutronFloatingIP.getID())) {
+ neutronPortForFloatIp = neutronPort;
+ break;
+ }
+ }
+
+ String neutronTenantPortUuid = neutronFloatingIP.getPortUUID();
+ if(neutronTenantPortUuid == null) {
+ return null;
+ }
+ Pair<Long, Uuid> nodeIfPair = this.getDpIdOfNeutronPort(neutronTenantPortUuid);
+ String floatingIpMac = neutronPortForFloatIp == null ? null : neutronPortForFloatIp.getMacAddress();
+ String fixedIpAddress = neutronFloatingIP.getFixedIPAddress();
+ String floatingIpAddress = neutronFloatingIP.getFloatingIPAddress();
+
+ NeutronPort tenantNeutronPort = neutronPortCache.getPort(neutronTenantPortUuid);
+ NeutronNetwork tenantNeutronNetwork = tenantNeutronPort != null ?
+ neutronNetworkCache.getNetwork(tenantNeutronPort.getNetworkUUID()) : null;
+ String providerSegmentationId = tenantNeutronNetwork != null ?
+ tenantNeutronNetwork.getProviderSegmentationID() : null;
+ String neutronRouterMac = tenantNeutronNetwork != null ?
+ networkIdToRouterMacCache.get(tenantNeutronNetwork.getID()) : null;
+
+ if (nodeIfPair == null || neutronTenantPortUuid == null ||
+ providerSegmentationId == null || providerSegmentationId.isEmpty() ||
+ floatingIpMac == null || floatingIpMac.isEmpty() ||
+ neutronRouterMac == null || neutronRouterMac.isEmpty()) {
+ LOG.debug("getFloatingIPWithMetadata :Floating IP {}<->{}, incomplete floatPort {} tenantPortUuid {} " +
+ "seg {} mac {} rtrMac {}",
+ fixedIpAddress,
+ floatingIpAddress,
+ neutronPortForFloatIp,
+ neutronTenantPortUuid,
+ providerSegmentationId,
+ floatingIpMac,
+ neutronRouterMac);
+
+ return null;
+ }
+
+ // get ofport for patch port in br-int
+ final Long dpId = nodeIfPair.getLeft();
+ final Long ofPort = findOFPortForExtPatch(dpId);
+ if (ofPort == null) {
+ LOG.warn("getFloatingIPWithMetadata : Unable to locate OF port of patch port " +
+ "to connect floating ip to external bridge. dpid {}",
+ dpId);
+ return null;
+ }
+
+ final FloatIpData floatIpData = new FloatIpData(dpId, ofPort, providerSegmentationId, floatingIpMac,
+ floatingIpAddress, fixedIpAddress, neutronRouterMac);
+ floatIpDataMapCache.put(neutronFloatingIP.getID(), floatIpData);
+
+ }
+ return floatIpDataMapCache.get(neutronFloatingId);
+ }
/**
* Invoked to configure the mac address for the external gateway in br-ex. ovsdb netvirt needs help in getting
* mac for given ip in br-ex (bug 3378). For example, since ovsdb has no real arp, it needs a service in can
private void programFlowsForFloatingIPInbound(final NeutronFloatingIP neutronFloatingIP, final Action action) {
Preconditions.checkNotNull(neutronFloatingIP);
- final FloatIpData fid = floatIpDataMapCache.get(neutronFloatingIP.getID());
+ final FloatIpData fid = getFloatingIPWithMetadata(neutronFloatingIP.getID());
if (fid == null) {
LOG.trace("programFlowsForFloatingIPInboundAdd {} for {} uuid {} not in local cache",
action, neutronFloatingIP.getFloatingIPAddress(), neutronFloatingIP.getID());
private void programFlowsForFloatingIPOutbound(final NeutronFloatingIP neutronFloatingIP, final Action action) {
Preconditions.checkNotNull(neutronFloatingIP);
- final FloatIpData fid = floatIpDataMapCache.get(neutronFloatingIP.getID());
+ final FloatIpData fid = getFloatingIPWithMetadata(neutronFloatingIP.getID());
if (fid == null) {
LOG.trace("programFlowsForFloatingIPOutbound {} for {} uuid {} not in local cache",
action, neutronFloatingIP.getFloatingIPAddress(), neutronFloatingIP.getID());
}
private void flushExistingIpRewrite() {
- for (FloatIpData fid : floatIpDataMapCache.values()) {
+ for (FloatIpData fid : getAllFloatingIPsWithMetadata()) {
programOutboundIpRewriteStage1(fid, Action.DELETE);
}
}
private void rebuildExistingIpRewrite() {
- for (FloatIpData fid : floatIpDataMapCache.values()) {
+ for (FloatIpData fid : getAllFloatingIPsWithMetadata()) {
programOutboundIpRewriteStage1(fid, Action.ADD);
}
}
Preconditions.checkNotNull(neutronFloatingIP.getFixedIPAddress());
Preconditions.checkNotNull(neutronFloatingIP.getFloatingIPAddress());
- if (floatIpDataMapCache.get(neutronFloatingIP.getID()) != null) {
- LOG.trace("programFlowsForFloatingIPArpAdd for neutronFloatingIP {} uuid {} is already done",
- neutronFloatingIP.getFloatingIPAddress(), neutronFloatingIP.getID());
- return;
- }
-
// find bridge Node where floating ip is configured by looking up cache for its port
final NeutronPort neutronPortForFloatIp = findNeutronPortForFloatingIp(neutronFloatingIP.getID());
final String neutronTenantPortUuid = neutronFloatingIP.getPortUUID();
- final Pair<Long, Uuid> nodeIfPair = neutronPortToDpIdCache.get(neutronTenantPortUuid);
+ final Pair<Long, Uuid> nodeIfPair = this.getDpIdOfNeutronPort(neutronTenantPortUuid);
final String floatingIpMac = neutronPortForFloatIp == null ? null : neutronPortForFloatIp.getMacAddress();
final String fixedIpAddress = neutronFloatingIP.getFixedIPAddress();
final String floatingIpAddress = neutronFloatingIP.getFloatingIPAddress();
}
private void programFlowsForFloatingIPArpDelete(final String neutronFloatingIPUuid) {
- final FloatIpData floatIpData = floatIpDataMapCache.get(neutronFloatingIPUuid);
+ final FloatIpData floatIpData = getFloatingIPWithMetadata(neutronFloatingIPUuid);
if (floatIpData == null) {
LOG.trace("programFlowsForFloatingIPArpDelete for uuid {} is not needed", neutronFloatingIPUuid);
return;
if (neutronPort != null) {
final String neutronPortUuid = neutronPort.getPortUUID();
- if (action != Action.DELETE && neutronPortToDpIdCache.get(neutronPortUuid) == null &&
- dpId != null && interfaceUuid != null) {
+ if (action != Action.DELETE && dpId != null && interfaceUuid != null) {
handleInterfaceEventAdd(neutronPortUuid, dpId, interfaceUuid);
}
private List<NeutronSecurityGroup> getsecurityGroupChanged(NeutronPort port1, NeutronPort port2) {
LOG.trace("getsecurityGroupChanged:" + "Port1:" + port1 + "Port2" + port2);
- ArrayList<NeutronSecurityGroup> list1 = new ArrayList<NeutronSecurityGroup>(port1.getSecurityGroups());
- ArrayList<NeutronSecurityGroup> list2 = new ArrayList<NeutronSecurityGroup>(port2.getSecurityGroups());
+ List<NeutronSecurityGroup> list1 = new ArrayList<>(port1.getSecurityGroups());
+ List<NeutronSecurityGroup> list2 = new ArrayList<>(port2.getSecurityGroups());
for (Iterator<NeutronSecurityGroup> iterator = list1.iterator(); iterator.hasNext();) {
NeutronSecurityGroup securityGroup1 = iterator.next();
for (NeutronSecurityGroup securityGroup2 :list2) {
private void programL3ForwardingStage1(Node node, Long dpid, String providerSegmentationId,
String macAddress, String ipStr,
Action actionForNode) {
- // Based on the local cache, figure out whether programming needs to occur. To do this, we
- // will look at desired action for node.
-
- final String cacheKey = node.getNodeId().getValue() + ":" + providerSegmentationId + ":" + ipStr;
- final boolean isProgrammed = l3ForwardingCache.contains(cacheKey);
-
- if (actionForNode == Action.DELETE && !isProgrammed) {
- LOG.trace("programL3ForwardingStage1 for node {} providerId {} mac {} ip {} action {} is already done",
+ if (actionForNode == Action.DELETE) {
+ LOG.trace("Deleting Flow : programL3ForwardingStage1 for node {} providerId {} mac {} ip {} action {}",
node.getNodeId().getValue(), providerSegmentationId, macAddress, ipStr, actionForNode);
- return;
}
- if (actionForNode == Action.ADD && isProgrammed) {
- LOG.trace("programL3ForwardingStage1 for node {} providerId {} mac {} ip {} action {} is already done",
+ if (actionForNode == Action.ADD) {
+ LOG.trace("Adding Flow : programL3ForwardingStage1 for node {} providerId {} mac {} ip {} action {}",
node.getNodeId().getValue(), providerSegmentationId, macAddress, ipStr, actionForNode);
- return;
}
- Status status = this.programL3ForwardingStage2(node, dpid, providerSegmentationId,
+ this.programL3ForwardingStage2(node, dpid, providerSegmentationId,
macAddress, ipStr, actionForNode);
- if (status.isSuccess()) {
- // Update cache
- if (actionForNode == Action.ADD) {
- l3ForwardingCache.add(cacheKey);
- } else {
- l3ForwardingCache.remove(cacheKey);
- }
- }
}
private Status programL3ForwardingStage2(Node node, Long dpid, String providerSegmentationId,
String destinationSegmentationId,
String macAddress, String ipStr, int mask,
Action actionForNode) {
- // Based on the local cache, figure out whether programming needs to occur. To do this, we
- // will look at desired action for node.
- //
- final String cacheKey = node.getNodeId().getValue() + ":" +
- sourceSegmentationId + ":" + destinationSegmentationId + ":" +
- ipStr + "/" + Integer.toString(mask);
- final boolean isProgrammed = routerInterfacesCache.contains(cacheKey);
-
- if (actionForNode == Action.DELETE && !isProgrammed) {
- LOG.trace("programRouterInterfaceStage1 for node {} sourceSegId {} destSegId {} mac {} ip {} mask {}" +
- " action {} is already done",
+ if (actionForNode == Action.DELETE) {
+ LOG.trace("Deleting Flow : programRouterInterfaceStage1 for node {} sourceSegId {} destSegId {} mac {} ip {} mask {}" +
+ " action {}",
node.getNodeId().getValue(), sourceSegmentationId, destinationSegmentationId,
macAddress, ipStr, mask, actionForNode);
return;
}
- if (actionForNode == Action.ADD && isProgrammed) {
- LOG.trace("programRouterInterfaceStage1 for node {} sourceSegId {} destSegId {} mac {} ip {} mask {}" +
- " action {} is already done",
+ if (actionForNode == Action.ADD) {
+ LOG.trace("Adding Flow : programRouterInterfaceStage1 for node {} sourceSegId {} destSegId {} mac {} ip {} mask {}" +
+ " action {}",
node.getNodeId().getValue(), sourceSegmentationId, destinationSegmentationId,
macAddress, ipStr, mask, actionForNode);
- return;
}
- Status status = this.programRouterInterfaceStage2(node, dpid, sourceSegmentationId, destinationSegmentationId,
+ this.programRouterInterfaceStage2(node, dpid, sourceSegmentationId, destinationSegmentationId,
macAddress, ipStr, mask, actionForNode);
- if (status.isSuccess()) {
- // Update cache
- if (actionForNode == Action.ADD) {
- // TODO: multiTenantAwareRouter.addInterface(UUID.fromString(tenant), ...);
- routerInterfacesCache.add(cacheKey);
- } else {
- // TODO: multiTenantAwareRouter.removeInterface(...);
- routerInterfacesCache.remove(cacheKey);
- }
- }
}
private Status programRouterInterfaceStage2(Node node, Long dpid, String sourceSegmentationId,
private boolean programStaticArpStage1(Long dpid, String segOrOfPort,
String macAddress, String ipStr,
Action action) {
- // Based on the local cache, figure out whether programming needs to occur. To do this, we
- // will look at desired action for node.
- //
- final String cacheKey = dpid + ":" + segOrOfPort + ":" + ipStr;
- final boolean isProgrammed = staticArpEntryCache.contains(cacheKey);
-
- if (action == Action.DELETE && !isProgrammed) {
- LOG.trace("programStaticArpStage1 dpid {} segOrOfPort {} mac {} ip {} action {} is already done",
+ if (action == Action.DELETE ) {
+ LOG.trace("Deleting Flow : programStaticArpStage1 dpid {} segOrOfPort {} mac {} ip {} action {}",
dpid, segOrOfPort, macAddress, ipStr, action);
- return true;
}
- if (action == Action.ADD && isProgrammed) {
- LOG.trace("programStaticArpStage1 dpid {} segOrOfPort {} mac {} ip {} action {} is already done",
+ if (action == Action.ADD) {
+ LOG.trace("Adding Flow : programStaticArpStage1 dpid {} segOrOfPort {} mac {} ip {} action {} is already done",
dpid, segOrOfPort, macAddress, ipStr, action);
- return true;
}
Status status = this.programStaticArpStage2(dpid, segOrOfPort, macAddress, ipStr, action);
- if (status.isSuccess()) {
- // Update cache
- if (action == Action.ADD) {
- staticArpEntryCache.add(cacheKey);
- } else {
- staticArpEntryCache.remove(cacheKey);
- }
- return true;
- }
- return false;
+ return status.isSuccess();
}
private Status programStaticArpStage2(Long dpid,
private boolean programInboundIpRewriteStage1(Long dpid, Long inboundOFPort, String providerSegmentationId,
String matchAddress, String rewriteAddress,
Action action) {
- // Based on the local cache, figure out whether programming needs to occur. To do this, we
- // will look at desired action for node.
- //
- final String cacheKey = dpid + ":" + inboundOFPort + ":" + providerSegmentationId + ":" + matchAddress;
- final boolean isProgrammed = inboundIpRewriteCache.contains(cacheKey);
-
- if (action == Action.DELETE && !isProgrammed) {
- LOG.trace("programInboundIpRewriteStage1 dpid {} OFPort {} seg {} matchAddress {} rewriteAddress {}" +
- " action {} is already done",
+ if (action == Action.DELETE ) {
+ LOG.trace("Deleting Flow : programInboundIpRewriteStage1 dpid {} OFPort {} seg {} matchAddress {} rewriteAddress {}" +
+ " action {}",
dpid, inboundOFPort, providerSegmentationId, matchAddress, rewriteAddress, action);
- return true;
}
- if (action == Action.ADD && isProgrammed) {
- LOG.trace("programInboundIpRewriteStage1 dpid {} OFPort {} seg {} matchAddress {} rewriteAddress {}" +
- " action is already done",
+ if (action == Action.ADD ) {
+ LOG.trace("Adding Flow : programInboundIpRewriteStage1 dpid {} OFPort {} seg {} matchAddress {} rewriteAddress {}" +
+ " action {}",
dpid, inboundOFPort, providerSegmentationId, matchAddress, rewriteAddress, action);
- return true;
}
Status status = programInboundIpRewriteStage2(dpid, inboundOFPort, providerSegmentationId, matchAddress,
rewriteAddress, action);
- if (status.isSuccess()) {
- // Update cache
- if (action == Action.ADD) {
- inboundIpRewriteCache.add(cacheKey);
- } else {
- inboundIpRewriteCache.remove(cacheKey);
- }
- return true;
- }
- return false;
+ return status.isSuccess();
}
private Status programInboundIpRewriteStage2(Long dpid, Long inboundOFPort, String providerSegmentationId,
private void programIpRewriteExclusionStage1(Node node, Long dpid, String providerSegmentationId, String cidr,
Action actionForRewriteExclusion) {
- // Based on the local cache, figure out whether programming needs to occur. To do this, we
- // will look at desired action for node.
- //
- final String cacheKey = node.getNodeId().getValue() + ":" + providerSegmentationId + ":" + cidr;
- final boolean isProgrammed = outboundIpRewriteExclusionCache.contains(cacheKey);
-
- if (actionForRewriteExclusion == Action.DELETE && !isProgrammed) {
- LOG.trace("programIpRewriteExclusionStage1 node {} providerId {} cidr {} action {} is already done",
+ if (actionForRewriteExclusion == Action.DELETE ) {
+ LOG.trace("Deleting Flow : programIpRewriteExclusionStage1 node {} providerId {} cidr {} action {}",
node.getNodeId().getValue(), providerSegmentationId, cidr, actionForRewriteExclusion);
- return;
}
- if (actionForRewriteExclusion == Action.ADD && isProgrammed) {
- LOG.trace("programIpRewriteExclusionStage1 node {} providerId {} cidr {} action {} is already done",
+ if (actionForRewriteExclusion == Action.ADD) {
+ LOG.trace("Adding Flow : programIpRewriteExclusionStage1 node {} providerId {} cidr {} action {}",
node.getNodeId().getValue(), providerSegmentationId, cidr, actionForRewriteExclusion);
- return;
}
- Status status = this.programIpRewriteExclusionStage2(node, dpid, providerSegmentationId, cidr,
- actionForRewriteExclusion);
- if (status.isSuccess()) {
- // Update cache
- if (actionForRewriteExclusion == Action.ADD) {
- outboundIpRewriteExclusionCache.add(cacheKey);
- } else {
- outboundIpRewriteExclusionCache.remove(cacheKey);
- }
- }
+ this.programIpRewriteExclusionStage2(node, dpid, providerSegmentationId, cidr,actionForRewriteExclusion);
}
private Status programIpRewriteExclusionStage2(Node node, Long dpid, String providerSegmentationId, String cidr,
}
private void programOutboundIpRewriteStage1(FloatIpData fid, Action action) {
- // Based on the local cache, figure out whether programming needs to occur. To do this, we
- // will look at desired action for node.
- //
- final String cacheKey = fid.dpid + ":" + fid.segId + ":" + fid.fixedIpAddress;
- final boolean isProgrammed = outboundIpRewriteCache.contains(cacheKey);
- if (action == Action.DELETE && !isProgrammed) {
- LOG.trace("programOutboundIpRewriteStage1 dpid {} seg {} fixedIpAddress {} floatIp {} action {} " +
- "is already done",
+ if (action == Action.DELETE) {
+ LOG.trace("Deleting Flow : programOutboundIpRewriteStage1 dpid {} seg {} fixedIpAddress {} floatIp {} action {} ",
fid.dpid, fid.segId, fid.fixedIpAddress, fid.floatingIpAddress, action);
- return;
}
- if (action == Action.ADD && isProgrammed) {
- LOG.trace("programOutboundIpRewriteStage1 dpid {} seg {} fixedIpAddress {} floatIp {} action {} " +
- "is already done",
+ if (action == Action.ADD) {
+ LOG.trace("Adding Flow : programOutboundIpRewriteStage1 dpid {} seg {} fixedIpAddress {} floatIp {} action {} " ,
fid.dpid, fid.segId, fid.fixedIpAddress, fid.floatingIpAddress, action);
- return;
}
- Status status = this.programOutboundIpRewriteStage2(fid, action);
- if (status.isSuccess()) {
- // Update cache
- if (action == Action.ADD) {
- outboundIpRewriteCache.add(cacheKey);
- } else {
- outboundIpRewriteCache.remove(cacheKey);
- }
- }
+ this.programOutboundIpRewriteStage2(fid, action);
}
private Status programOutboundIpRewriteStage2(FloatIpData fid, Action action) {
neutronPortCache = (INeutronPortCRUD)impl;
} else if (impl instanceof INeutronSubnetCRUD) {
neutronSubnetCache = (INeutronSubnetCRUD)impl;
+ } else if (impl instanceof INeutronFloatingIPCRUD) {
+ neutronFloatingIpCache = (INeutronFloatingIPCRUD)impl;
} else if (impl instanceof ArpProvider) {
arpProvider = (ArpProvider)impl;
} else if (impl instanceof InboundNatProvider) {
}else if (impl instanceof GatewayMacResolver) {
gatewayMacResolver = (GatewayMacResolver)impl;
}
+ populateL3ForwardingCaches();
}
}
return nodes;
}
+ private void populateNodeCache() {
+ LOG.debug("populateNodeCache : Populating the node cache");
+ List<Node> nodes = southbound.readOvsdbTopologyNodes();
+ for(Node ovsdbNode : nodes) {
+ this.nodeCache.put(ovsdbNode.getNodeId(), ovsdbNode);
+ }
+ nodes = southbound.readOvsdbTopologyBridgeNodes();
+ for(Node bridgeNode : nodes) {
+ this.nodeCache.put(bridgeNode.getNodeId(), bridgeNode);
+ }
+ LOG.debug("populateNodeCache : Node cache population is done. Total nodes : {}",this.nodeCache.size());
+ }
+
@Override
public void setDependencies(ServiceReference serviceReference) {
southbound =
eventDispatcher =
(EventDispatcher) ServiceHelper.getGlobalInstance(EventDispatcher.class, this);
eventDispatcher.eventHandlerAdded(serviceReference, this);
+ populateNodeCache();
}
@Override
import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl.NeutronNetworkChangeListener;
import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl.NeutronPortChangeListener;
import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl.NeutronRouterChangeListener;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl.NeutronSecurityRuleDataChangeListener;
import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl.NeutronSubnetChangeListener;
import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl.NeutronLoadBalancerPoolChangeListener;
import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl.NeutronLoadBalancerPoolMemberChangeListener;
new NeutronFloatingIPChangeListener(db);
new NeutronLoadBalancerPoolChangeListener(db);
new NeutronLoadBalancerPoolMemberChangeListener(db);
+ new NeutronSecurityRuleDataChangeListener(db);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2014, 2015 HP, 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.ovsdb.openstack.netvirt.impl;
+
+import org.opendaylight.ovsdb.openstack.netvirt.ConfigInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityGroupCacheManger;
+import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * @author Aswin Suryanarayanan.
+ */
+
+public class SecurityGroupCacheManagerImpl implements ConfigInterface, SecurityGroupCacheManger{
+
+ private final Map<String, Set<String>> securityGroupCache = new ConcurrentHashMap<>();
+ private static final Logger LOG = LoggerFactory.getLogger(SecurityGroupCacheManagerImpl.class);
+ private volatile SecurityServicesManager securityServicesManager;
+ private volatile INeutronPortCRUD neutronPortCache;
+
+ @Override
+ public void portAdded(String securityGroupUuid, String portUuid) {
+ LOG.debug("In portAdded securityGroupUuid:" + securityGroupUuid + " portUuid:" + portUuid);
+ NeutronPort port = neutronPortCache.getPort(portUuid);
+ processPortAdded(securityGroupUuid,port);
+ }
+
+ @Override
+ public void portRemoved(String securityGroupUuid, String portUuid) {
+ LOG.debug("In portRemoved securityGroupUuid:" + securityGroupUuid + " portUuid:" + portUuid);
+ NeutronPort port = neutronPortCache.getPort(portUuid);
+ processPortRemoved(securityGroupUuid,port);
+ }
+
+ @Override
+ public void addToCache(String remoteSgUuid, String portUuid) {
+ LOG.debug("In addToCache remoteSgUuid:" + remoteSgUuid + "portUuid:" + portUuid);
+ Set<String> portList = securityGroupCache.get(remoteSgUuid);
+ if (null == portList) {
+ portList = new HashSet<>();
+ securityGroupCache.put(remoteSgUuid, portList);
+ }
+ portList.add(portUuid);
+ }
+
+ @Override
+ public void removeFromCache(String remoteSgUuid, String portUuid) {
+ LOG.debug("In removeFromCache remoteSgUuid:" + remoteSgUuid + " portUuid:" + portUuid);
+ Set<String> portList = securityGroupCache.get(remoteSgUuid);
+ if (null == portList) {
+ return;
+ }
+ for (Iterator<String> iterator = portList.iterator(); iterator.hasNext();) {
+ String cachedPort = iterator.next();
+ if (cachedPort.equals(portUuid)) {
+ iterator.remove();
+ break;
+ }
+ }
+ if (portList.isEmpty()) {
+ securityGroupCache.remove(remoteSgUuid);
+ }
+ }
+
+ private void processPortAdded(String securityGroupUuid, NeutronPort port) {
+ /*
+ * Itreate through the cache maintained for the security group added. For each port in the cache
+ * add the rule to allow traffic to/from the new port added.
+ */
+ LOG.debug("In processPortAdded securityGroupUuid:" + securityGroupUuid + " NeutronPort:" + port);
+ Set<String> portList = this.securityGroupCache.get(securityGroupUuid);
+ if (null == portList) {
+ return;
+ }
+ for (String cachedportUuid : portList) {
+ if (cachedportUuid.equals(port.getID())) {
+ continue;
+ }
+ NeutronPort cachedport = neutronPortCache.getPort(cachedportUuid);
+ if (null == cachedport) {
+ return;
+ }
+ List<NeutronSecurityRule> remoteSecurityRules = retrieveSecurityRules(securityGroupUuid, cachedportUuid);
+ for (NeutronSecurityRule securityRule : remoteSecurityRules) {
+ for (Neutron_IPs vmIp : port.getFixedIPs()) {
+ securityServicesManager.syncSecurityRule(cachedport, securityRule, vmIp, true);
+ }
+ }
+ }
+ }
+
+ private void processPortRemoved(String securityGroupUuid, NeutronPort port) {
+ /*
+ * Itreate through the cache maintained for the security group added. For each port in the cache remove
+ * the rule to allow traffic to/from the port that got deleted.
+ */
+ LOG.debug("In processPortRemoved securityGroupUuid:" + securityGroupUuid + " port:" + port);
+ Set<String> portList = this.securityGroupCache.get(securityGroupUuid);
+ if (null == portList) {
+ return;
+ }
+ for (String cachedportUuid : portList) {
+ if (cachedportUuid.equals(port.getID())) {
+ continue;
+ }
+ NeutronPort cachedport = neutronPortCache.getPort(cachedportUuid);
+ if (null == cachedport) {
+ return;
+ }
+ List<NeutronSecurityRule> remoteSecurityRules = retrieveSecurityRules(securityGroupUuid, cachedportUuid);
+ for (NeutronSecurityRule securityRule : remoteSecurityRules) {
+ for (Neutron_IPs vmIp : port.getFixedIPs()) {
+ securityServicesManager.syncSecurityRule(cachedport, securityRule, vmIp, false);
+ }
+ }
+ }
+ }
+
+ private List<NeutronSecurityRule> retrieveSecurityRules(String securityGroupUuid, String portUuid) {
+ /*
+ * Get the list of security rules in the port with portUuid that has securityGroupUuid as a remote
+ * security group.
+ */
+ LOG.debug("In retrieveSecurityRules securityGroupUuid:" + securityGroupUuid + " portUuid:" + portUuid);
+ NeutronPort port = neutronPortCache.getPort(portUuid);
+ if (null == port) {
+ return null;
+ }
+ List<NeutronSecurityRule> remoteSecurityRules = new ArrayList<>();
+ List<NeutronSecurityGroup> securityGroups = port.getSecurityGroups();
+ for (NeutronSecurityGroup securityGroup : securityGroups) {
+ List<NeutronSecurityRule> securityRules = securityGroup.getSecurityRules();
+ for (NeutronSecurityRule securityRule : securityRules) {
+ if (securityGroupUuid.equals(securityRule.getSecurityRemoteGroupID())) {
+ remoteSecurityRules.add(securityRule);
+ }
+ }
+ }
+ return remoteSecurityRules;
+ }
+
+ private void init() {
+ /*
+ * Rebuild the cache in case of a restart.
+ */
+ List<NeutronPort> portList = neutronPortCache.getAllPorts();
+ for (NeutronPort port:portList) {
+ List<NeutronSecurityGroup> securityGroupList = port.getSecurityGroups();
+ if ( null != securityGroupList) {
+ for (NeutronSecurityGroup securityGroup : securityGroupList) {
+ List<NeutronSecurityRule> securityRuleList = securityGroup.getSecurityRules();
+ if ( null != securityRuleList) {
+ for (NeutronSecurityRule securityRule : securityRuleList) {
+ if (null != securityRule.getSecurityRemoteGroupID()) {
+ this.addToCache(securityRule.getSecurityRemoteGroupID(), port.getID());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void setDependencies(ServiceReference serviceReference) {
+ securityServicesManager =
+ (SecurityServicesManager) ServiceHelper.getGlobalInstance(SecurityServicesManager.class, this);
+ neutronPortCache = (INeutronPortCRUD) ServiceHelper.getGlobalInstance(INeutronPortCRUD.class, this);
+ init();
+ }
+
+ @Override
+ public void setDependencies(Object impl) {
+ }
+}
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnet;
import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
private volatile ConfigurationService configurationService;
private volatile IngressAclProvider ingressAclProvider;
private volatile EgressAclProvider egressAclProvider;
- private volatile SecurityServicesManager securityServicesManager;
@Override
public boolean isPortSecurityReady(OvsdbTerminationPointAugmentation terminationPointAugmentation) {
@Override
public List<NeutronSecurityGroup> getSecurityGroupInPortList(OvsdbTerminationPointAugmentation
terminationPointAugmentation) {
- List<NeutronSecurityGroup> neutronSecurityGroups = new ArrayList<NeutronSecurityGroup>();
+ List<NeutronSecurityGroup> neutronSecurityGroups = new ArrayList<>();
if (neutronPortCache == null) {
LOG.error("neutron port is null");
return neutronSecurityGroups;
}
@Override
- public List<Neutron_IPs> getVmListForSecurityGroup(List<Neutron_IPs> srcAddressList, String securityGroupUuid) {
- List<Neutron_IPs> vmListForSecurityGroup = new ArrayList<Neutron_IPs>();
+ public List<Neutron_IPs> getVmListForSecurityGroup(String portUuid, String securityGroupUuid) {
+ List<Neutron_IPs> vmListForSecurityGroup = new ArrayList<>();
/*For every port check whether security grouplist contains the current
* security group.*/
try {
+ "compute port belongs to {}", neutronPort.getID(), neutronPort.getDeviceOwner());
continue;
}
+ if (portUuid.equals(neutronPort.getID())) {
+ continue;
+ }
List<NeutronSecurityGroup> securityGroups = neutronPort.getSecurityGroups();
if (null != securityGroups) {
for (NeutronSecurityGroup securityGroup:securityGroups) {
- if (securityGroup.getSecurityGroupUUID().equals(securityGroupUuid)
- && !neutronPort.getFixedIPs().containsAll(srcAddressList)) {
+ if (securityGroup.getSecurityGroupUUID().equals(securityGroupUuid)) {
LOG.debug("getVMListForSecurityGroup : adding ports with ips {} "
+ "compute port", neutronPort.getFixedIPs());
vmListForSecurityGroup.addAll(neutronPort.getFixedIPs());
@Override
public void syncSecurityGroup(NeutronPort port, List<NeutronSecurityGroup> securityGroupList, boolean write) {
- LOG.trace("syncSecurityGroup:" + securityGroupList + " Write:" + Boolean.valueOf(write));
+ LOG.trace("syncSecurityGroup:" + securityGroupList + " Write:" + write);
if (null != port && null != port.getSecurityGroups()) {
Node node = getNode(port);
NeutronNetwork neutronNetwork = neutronNetworkCache.getNetwork(port.getNetworkUUID());
return;
}
long dpid = getDpidOfIntegrationBridge(node);
- List<Neutron_IPs> srcAddressList = securityServicesManager.getIpAddressList(node, intf);
+ String neutronPortId = southbound.getInterfaceExternalIdsValue(intf,
+ Constants.EXTERNAL_ID_INTERFACE_ID);
for (NeutronSecurityGroup securityGroupInPort:securityGroupList) {
- ingressAclProvider.programPortSecurityAcl(dpid, segmentationId, attachedMac, localPort,
- securityGroupInPort, srcAddressList, write);
- egressAclProvider.programPortSecurityAcl(dpid, segmentationId, attachedMac, localPort,
- securityGroupInPort, srcAddressList, write);
+ ingressAclProvider.programPortSecurityGroup(dpid, segmentationId, attachedMac, localPort,
+ securityGroupInPort, neutronPortId, write);
+ egressAclProvider.programPortSecurityGroup(dpid, segmentationId, attachedMac, localPort,
+ securityGroupInPort, neutronPortId, write);
+ }
+ }
+ }
+
+ @Override
+ public void syncSecurityRule(NeutronPort port, NeutronSecurityRule securityRule,Neutron_IPs vmIp, boolean write) {
+ LOG.trace("syncSecurityGroup:" + securityRule + " Write:" + write);
+ if (null != port && null != port.getSecurityGroups()) {
+ Node node = getNode(port);
+ NeutronNetwork neutronNetwork = neutronNetworkCache.getNetwork(port.getNetworkUUID());
+ String segmentationId = neutronNetwork.getProviderSegmentationID();
+ OvsdbTerminationPointAugmentation intf = getInterface(node, port);
+ long localPort = southbound.getOFPort(intf);
+ String attachedMac = southbound.getInterfaceExternalIdsValue(intf, Constants.EXTERNAL_ID_VM_MAC);
+ if (attachedMac == null) {
+ LOG.debug("programVlanRules: No AttachedMac seen in {}", intf);
+ return;
+ }
+ long dpid = getDpidOfIntegrationBridge(node);
+ if ("IPv4".equals(securityRule.getSecurityRuleEthertype())
+ && "ingress".equals(securityRule.getSecurityRuleDirection())) {
+
+ ingressAclProvider.programPortSecurityRule(dpid, segmentationId, attachedMac, localPort,
+ securityRule, vmIp, write);
+ } else if (securityRule.getSecurityRuleEthertype().equals("IPv4")
+ && securityRule.getSecurityRuleDirection().equals("egress")) {
+ egressAclProvider.programPortSecurityRule(dpid, segmentationId, attachedMac, localPort,
+ securityRule, vmIp, write);
}
}
}
(INeutronNetworkCRUD) ServiceHelper.getGlobalInstance(INeutronNetworkCRUD.class, this);
configurationService =
(ConfigurationService) ServiceHelper.getGlobalInstance(ConfigurationService.class, this);
- securityServicesManager =
- (SecurityServicesManager) ServiceHelper.getGlobalInstance(SecurityServicesManager.class, this);
}
@Override
egressAclProvider = (EgressAclProvider) impl;
}
}
-}
+}
\ No newline at end of file
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeExternalIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeOtherConfigs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeOtherConfigsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeOtherConfigsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ProtocolEntry;
return ovsdbNodes;
}
+ public List<Node> readOvsdbTopologyBridgeNodes() {
+ List<Node> ovsdbNodes = new ArrayList<>();
+ InstanceIdentifier<Topology> topologyInstanceIdentifier = MdsalHelper.createInstanceIdentifier();
+ Topology topology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, topologyInstanceIdentifier);
+ if (topology != null && topology.getNode() != null) {
+ for (Node node : topology.getNode()) {
+ OvsdbBridgeAugmentation ovsdbBridgeAugmentation = node.getAugmentation(OvsdbBridgeAugmentation.class);
+ if (ovsdbBridgeAugmentation != null) {
+ ovsdbNodes.add(node);
+ }
+ }
+ }
+ return ovsdbNodes;
+ }
+
public Node readOvsdbNode(Node bridgeNode) {
Node ovsdbNode = null;
OvsdbBridgeAugmentation bridgeAugmentation = extractBridgeAugmentation(bridgeNode);
ovsdbBridgeAugmentationBuilder.setProtocolEntry(createMdsalProtocols());
ovsdbBridgeAugmentationBuilder.setFailMode(
MdsalHelper.OVSDB_FAIL_MODE_MAP.inverse().get("secure"));
+ BridgeOtherConfigsBuilder bridgeOtherConfigsBuilder = new BridgeOtherConfigsBuilder();
+ bridgeOtherConfigsBuilder.setBridgeOtherConfigKey(MdsalHelper.DISABLE_IN_BAND);
+ bridgeOtherConfigsBuilder.setBridgeOtherConfigValue("true");
+ bridgeOtherConfigsBuilder.setBridgeOtherConfigKey(MdsalHelper.DISABLE_IN_BAND);
+ List<BridgeOtherConfigs> bridgeOtherConfigsList = new ArrayList<>();
+ bridgeOtherConfigsList.add(bridgeOtherConfigsBuilder.build());
+ ovsdbBridgeAugmentationBuilder.setBridgeOtherConfigs(bridgeOtherConfigsList);
setManagedByForBridge(ovsdbBridgeAugmentationBuilder, ovsdbNode.getKey());
if (isOvsdbNodeDpdk(ovsdbNode)) {
ovsdbBridgeAugmentationBuilder.setDatapathType(DatapathTypeNetdev.class);
}
private List<ProtocolEntry> createMdsalProtocols() {
- List<ProtocolEntry> protocolList = new ArrayList<ProtocolEntry>();
+ List<ProtocolEntry> protocolList = new ArrayList<>();
ImmutableBiMap<String, Class<? extends OvsdbBridgeProtocolBase>> mapper =
MdsalHelper.OVSDB_PROTOCOL_MAP.inverse();
protocolList.add(new ProtocolEntryBuilder().
- setProtocol((Class<? extends OvsdbBridgeProtocolBase>) mapper.get("OpenFlow13")).build());
+ setProtocol(mapper.get("OpenFlow13")).build());
return protocolList;
}
}
public List<Node> getAllBridgesOnOvsdbNode(Node node) {
- List<Node> nodes = new ArrayList<Node>();
+ List<Node> nodes = new ArrayList<>();
List<ManagedNodeEntry> managedNodes = node.getAugmentation(OvsdbNodeAugmentation.class).getManagedNodeEntry();
for (ManagedNodeEntry managedNode : managedNodes) {
InstanceIdentifier<?> bridgeIid = managedNode.getBridgeRef().getValue();
}
public List<TerminationPoint> extractTerminationPoints(Node node) {
- List<TerminationPoint> terminationPoints = new ArrayList<TerminationPoint>();
+ List<TerminationPoint> terminationPoints = new ArrayList<>();
OvsdbBridgeAugmentation ovsdbBridgeAugmentation = node.getAugmentation(OvsdbBridgeAugmentation.class);
if (ovsdbBridgeAugmentation != null) {
terminationPoints.addAll(node.getTerminationPoint());
}
public List<OvsdbTerminationPointAugmentation> extractTerminationPointAugmentations( Node node ) {
- List<OvsdbTerminationPointAugmentation> tpAugmentations = new ArrayList<OvsdbTerminationPointAugmentation>();
+ List<OvsdbTerminationPointAugmentation> tpAugmentations = new ArrayList<>();
List<TerminationPoint> terminationPoints = node.getTerminationPoint();
if(terminationPoints != null && !terminationPoints.isEmpty()){
for(TerminationPoint tp : terminationPoints){
if(operNode != null){
return extractTerminationPointAugmentations(operNode);
}
- return new ArrayList<OvsdbTerminationPointAugmentation>();
+ return new ArrayList<>();
}
public String getInterfaceExternalIdsValue(
tpAugmentationBuilder.setInterfaceType(MdsalHelper.OVSDB_INTERFACE_TYPE_MAP.get(type));
}
- List<Options> optionsList = new ArrayList<Options>();
+ List<Options> optionsList = new ArrayList<>();
for (Map.Entry<String, String> entry : options.entrySet()) {
OptionsBuilder optionsBuilder = new OptionsBuilder();
optionsBuilder.setKey(new OptionsKey(entry.getKey()));
}
public Boolean addPatchTerminationPoint(Node node, String bridgeName, String portName, String peerPortName) {
- Map<String, String> option = new HashMap<String, String>();
+ Map<String, String> option = new HashMap<>();
option.put("peer", peerPortName);
return addTerminationPoint(node, bridgeName, portName, PATCH_PORT_TYPE, option);
}
.create(NetworkTopology.class)
.child(Topology.class, new TopologyKey(MdsalHelper.OVSDB_TOPOLOGY_ID));
- Topology topology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, path);
- return topology;
+ return mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, path);
}
public Long getOFPort(OvsdbTerminationPointAugmentation port) {
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
/**
public NeutronFirewall extractFields(List<String> fields) {
NeutronFirewall ans = new NeutronFirewall();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("tenant_id")) {
- ans.setFirewallTenantID(this.getFirewallTenantID());
- }
- if (s.equals("name")) {
- ans.setFirewallName(this.getFirewallName());
- }
- if(s.equals("description")) {
- ans.setFirewallDescription(this.getFirewallDescription());
- }
- if (s.equals("admin_state_up")) {
- ans.setFirewallAdminStateIsUp(firewallAdminStateIsUp);
- }
- if (s.equals("status")) {
- ans.setFirewallStatus(this.getFirewallStatus());
- }
- if (s.equals("shared")) {
- ans.setFirewallIsShared(firewallIsShared);
- }
- if (s.equals("firewall_policy_id")) {
- ans.setNeutronFirewallPolicyID(this.getFirewallPolicyID());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "tenant_id":
+ ans.setFirewallTenantID(this.getFirewallTenantID());
+ break;
+ case "name":
+ ans.setFirewallName(this.getFirewallName());
+ break;
+ case "description":
+ ans.setFirewallDescription(this.getFirewallDescription());
+ break;
+ case "admin_state_up":
+ ans.setFirewallAdminStateIsUp(firewallAdminStateIsUp);
+ break;
+ case "status":
+ ans.setFirewallStatus(this.getFirewallStatus());
+ break;
+ case "shared":
+ ans.setFirewallIsShared(firewallIsShared);
+ break;
+ case "firewall_policy_id":
+ ans.setNeutronFirewallPolicyID(this.getFirewallPolicyID());
+ break;
}
}
return ans;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
/**
public NeutronFirewallPolicy extractFields(List<String> fields) {
NeutronFirewallPolicy ans = new NeutronFirewallPolicy();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("tenant_id")) {
- ans.setFirewallPolicyTenantID(this.getFirewallPolicyTenantID());
- }
- if (s.equals("name")) {
- ans.setFirewallPolicyName(this.getFirewallPolicyName());
- }
- if(s.equals("description")) {
- ans.setFirewallPolicyDescription(this.getFirewallPolicyDescription());
- }
- if (s.equals("shared")) {
- ans.setFirewallPolicyIsShared(firewallPolicyIsShared);
- }
- if (s.equals("firewall_rules")) {
- List<String> firewallRuleList = new ArrayList<String>();
- firewallRuleList.addAll(this.getFirewallPolicyRules());
- ans.setFirewallPolicyRules(firewallRuleList);
- }
- if (s.equals("audited")) {
- ans.setFirewallPolicyIsAudited(firewallPolicyIsAudited);
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "tenant_id":
+ ans.setFirewallPolicyTenantID(this.getFirewallPolicyTenantID());
+ break;
+ case "name":
+ ans.setFirewallPolicyName(this.getFirewallPolicyName());
+ break;
+ case "description":
+ ans.setFirewallPolicyDescription(this.getFirewallPolicyDescription());
+ break;
+ case "shared":
+ ans.setFirewallPolicyIsShared(firewallPolicyIsShared);
+ break;
+ case "firewall_rules":
+ List<String> firewallRuleList = new ArrayList<>();
+ firewallRuleList.addAll(this.getFirewallPolicyRules());
+ ans.setFirewallPolicyRules(firewallRuleList);
+ break;
+ case "audited":
+ ans.setFirewallPolicyIsAudited(firewallPolicyIsAudited);
+ break;
}
}
return ans;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
/**
public NeutronFirewallRule extractFields(List<String> fields) {
NeutronFirewallRule ans = new NeutronFirewallRule();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("tenant_id")) {
- ans.setFirewallRuleTenantID(this.getFirewallRuleTenantID());
- }
- if (s.equals("name")) {
- ans.setFirewallRuleName(this.getFirewallRuleName());
- }
- if (s.equals("description")) {
- ans.setFirewallRuleDescription(this.getFirewallRuleDescription());
- }
- if (s.equals("status")) {
- ans.setFirewallRuleStatus(this.getFirewallRuleStatus());
- }
- if (s.equals("shared")) {
- ans.setFirewallRuleIsShared(firewallRuleIsShared);
- }
- if (s.equals("firewall_policy_id")) {
- ans.setFirewallRulesPolicyID(this.getFirewallRulePolicyID());
- }
- if (s.equals("protocol")) {
- ans.setFirewallRuleProtocol(this.getFirewallRuleProtocol());
- }
- if (s.equals("source_ip_address")) {
- ans.setFirewallRuleSrcIpAddr(this.getFirewallRuleSrcIpAddr());
- }
- if (s.equals("destination_ip_address")) {
- ans.setFirewallRuleDstIpAddr(this.getFirewallRuleDstIpAddr());
- }
- if (s.equals("source_port")) {
- ans.setFirewallRuleSrcPort(this.getFirewallRuleSrcPort());
- }
- if (s.equals("destination_port")) {
- ans.setFirewallRuleDstPort(this.getFirewallRuleDstPort());
- }
- if (s.equals("position")) {
- ans.setFirewallRulePosition(this.getFirewallRulePosition());
- }
- if (s.equals("action")) {
- ans.setFirewallRuleAction(this.getFirewallRuleAction());
- }
- if (s.equals("enabled")) {
- ans.setFirewallRuleIsEnabled(firewallRuleIsEnabled);
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "tenant_id":
+ ans.setFirewallRuleTenantID(this.getFirewallRuleTenantID());
+ break;
+ case "name":
+ ans.setFirewallRuleName(this.getFirewallRuleName());
+ break;
+ case "description":
+ ans.setFirewallRuleDescription(this.getFirewallRuleDescription());
+ break;
+ case "status":
+ ans.setFirewallRuleStatus(this.getFirewallRuleStatus());
+ break;
+ case "shared":
+ ans.setFirewallRuleIsShared(firewallRuleIsShared);
+ break;
+ case "firewall_policy_id":
+ ans.setFirewallRulesPolicyID(this.getFirewallRulePolicyID());
+ break;
+ case "protocol":
+ ans.setFirewallRuleProtocol(this.getFirewallRuleProtocol());
+ break;
+ case "source_ip_address":
+ ans.setFirewallRuleSrcIpAddr(this.getFirewallRuleSrcIpAddr());
+ break;
+ case "destination_ip_address":
+ ans.setFirewallRuleDstIpAddr(this.getFirewallRuleDstIpAddr());
+ break;
+ case "source_port":
+ ans.setFirewallRuleSrcPort(this.getFirewallRuleSrcPort());
+ break;
+ case "destination_port":
+ ans.setFirewallRuleDstPort(this.getFirewallRuleDstPort());
+ break;
+ case "position":
+ ans.setFirewallRulePosition(this.getFirewallRulePosition());
+ break;
+ case "action":
+ ans.setFirewallRuleAction(this.getFirewallRuleAction());
+ break;
+ case "enabled":
+ ans.setFirewallRuleIsEnabled(firewallRuleIsEnabled);
+ break;
}
}
package org.opendaylight.ovsdb.openstack.netvirt.translator;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
public NeutronFloatingIP extractFields(List<String> fields) {
NeutronFloatingIP ans = new NeutronFloatingIP();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("floating_network_id")) {
- ans.setFloatingNetworkUUID(this.getFloatingNetworkUUID());
- }
- if (s.equals("port_id")) {
- ans.setPortUUID(this.getPortUUID());
- }
- if (s.equals("fixed_ip_address")) {
- ans.setFixedIPAddress(this.getFixedIPAddress());
- }
- if (s.equals("floating_ip_address")) {
- ans.setFloatingIPAddress(this.getFloatingIPAddress());
- }
- if (s.equals("tenant_id")) {
- ans.setTenantUUID(this.getTenantUUID());
- }
- if (s.equals("router_id")) {
- ans.setRouterUUID(this.getRouterUUID());
- }
- if (s.equals("status")) {
- ans.setStatus(this.getStatus());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "floating_network_id":
+ ans.setFloatingNetworkUUID(this.getFloatingNetworkUUID());
+ break;
+ case "port_id":
+ ans.setPortUUID(this.getPortUUID());
+ break;
+ case "fixed_ip_address":
+ ans.setFixedIPAddress(this.getFixedIPAddress());
+ break;
+ case "floating_ip_address":
+ ans.setFloatingIPAddress(this.getFloatingIPAddress());
+ break;
+ case "tenant_id":
+ ans.setTenantUUID(this.getTenantUUID());
+ break;
+ case "router_id":
+ ans.setRouterUUID(this.getRouterUUID());
+ break;
+ case "status":
+ ans.setStatus(this.getStatus());
+ break;
}
}
return ans;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
/**
public NeutronLoadBalancer extractFields(List<String> fields) {
NeutronLoadBalancer ans = new NeutronLoadBalancer();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("tenant_id")) {
- ans.setLoadBalancerTenantID(this.getLoadBalancerTenantID());
- }
- if (s.equals("name")) {
- ans.setLoadBalancerName(this.getLoadBalancerName());
- }
- if(s.equals("description")) {
- ans.setLoadBalancerDescription(this.getLoadBalancerDescription());
- }
- if (s.equals("vip_address")) {
- ans.setLoadBalancerVipAddress(this.getLoadBalancerVipAddress());
- }
- if (s.equals("vip_subnet_id")) {
- ans.setLoadBalancerVipSubnetID(this.getLoadBalancerVipSubnetID());
- }
- if (s.equals("status")) {
- ans.setLoadBalancerStatus(this.getLoadBalancerStatus());
- }
- if (s.equals("admin_state_up")) {
- ans.setLoadBalancerAdminStateUp(this.getLoadBalancerAdminStateUp());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "tenant_id":
+ ans.setLoadBalancerTenantID(this.getLoadBalancerTenantID());
+ break;
+ case "name":
+ ans.setLoadBalancerName(this.getLoadBalancerName());
+ break;
+ case "description":
+ ans.setLoadBalancerDescription(this.getLoadBalancerDescription());
+ break;
+ case "vip_address":
+ ans.setLoadBalancerVipAddress(this.getLoadBalancerVipAddress());
+ break;
+ case "vip_subnet_id":
+ ans.setLoadBalancerVipSubnetID(this.getLoadBalancerVipSubnetID());
+ break;
+ case "status":
+ ans.setLoadBalancerStatus(this.getLoadBalancerStatus());
+ break;
+ case "admin_state_up":
+ ans.setLoadBalancerAdminStateUp(this.getLoadBalancerAdminStateUp());
+ break;
}
}
return ans;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
/**
public NeutronLoadBalancerHealthMonitor extractFields(List<String> fields) {
NeutronLoadBalancerHealthMonitor ans = new NeutronLoadBalancerHealthMonitor();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("tenant_id")) {
- ans.setLoadBalancerHealthMonitorTenantID(this.getLoadBalancerHealthMonitorTenantID());
- }
- if (s.equals("type")) {
- ans.setLoadBalancerHealthMonitorType(this.getLoadBalancerHealthMonitorType());
- }
- if (s.equals("delay")) {
- ans.setLoadBalancerHealthMonitorDelay(this.getLoadBalancerHealthMonitorDelay());
- }
- if (s.equals("timeout")) {
- ans.setLoadBalancerHealthMonitorTimeout(this.getLoadBalancerHealthMonitorTimeout());
- }
- if (s.equals("max_retries")) {
- ans.setLoadBalancerHealthMonitorMaxRetries(this.getLoadBalancerHealthMonitorMaxRetries());
- }
- if (s.equals("http_method")) {
- ans.setLoadBalancerHealthMonitorHttpMethod(this.getLoadBalancerHealthMonitorHttpMethod());
- }
- if(s.equals("url_path")) {
- ans.setLoadBalancerHealthMonitorUrlPath(this.getLoadBalancerHealthMonitorUrlPath());
- }
- if (s.equals("expected_codes")) {
- ans.setLoadBalancerHealthMonitorExpectedCodes(this.getLoadBalancerHealthMonitorExpectedCodes());
- }
- if (s.equals("admin_state_up")) {
- ans.setLoadBalancerHealthMonitorAdminStateIsUp(loadBalancerHealthMonitorAdminStateIsUp);
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "tenant_id":
+ ans.setLoadBalancerHealthMonitorTenantID(this.getLoadBalancerHealthMonitorTenantID());
+ break;
+ case "type":
+ ans.setLoadBalancerHealthMonitorType(this.getLoadBalancerHealthMonitorType());
+ break;
+ case "delay":
+ ans.setLoadBalancerHealthMonitorDelay(this.getLoadBalancerHealthMonitorDelay());
+ break;
+ case "timeout":
+ ans.setLoadBalancerHealthMonitorTimeout(this.getLoadBalancerHealthMonitorTimeout());
+ break;
+ case "max_retries":
+ ans.setLoadBalancerHealthMonitorMaxRetries(this.getLoadBalancerHealthMonitorMaxRetries());
+ break;
+ case "http_method":
+ ans.setLoadBalancerHealthMonitorHttpMethod(this.getLoadBalancerHealthMonitorHttpMethod());
+ break;
+ case "url_path":
+ ans.setLoadBalancerHealthMonitorUrlPath(this.getLoadBalancerHealthMonitorUrlPath());
+ break;
+ case "expected_codes":
+ ans.setLoadBalancerHealthMonitorExpectedCodes(this.getLoadBalancerHealthMonitorExpectedCodes());
+ break;
+ case "admin_state_up":
+ ans.setLoadBalancerHealthMonitorAdminStateIsUp(loadBalancerHealthMonitorAdminStateIsUp);
+ break;
}
}
return ans;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
/**
public NeutronLoadBalancerListener extractFields(List<String> fields) {
NeutronLoadBalancerListener ans = new NeutronLoadBalancerListener();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if(s.equals("default_pool_id")) {
- ans.setNeutronLoadBalancerListenerDefaultPoolID(this.getNeutronLoadBalancerListenerDefaultPoolID());
- }
- if (s.equals("tenant_id")) {
- ans.setLoadBalancerListenerTenantID(this.getLoadBalancerListenerTenantID());
- }
- if (s.equals("name")) {
- ans.setLoadBalancerListenerName(this.getLoadBalancerListenerName());
- }
- if(s.equals("description")) {
- ans.setLoadBalancerListenerDescription(this.getLoadBalancerListenerDescription());
- }
- if (s.equals("protocol")) {
- ans.setNeutronLoadBalancerListenerProtocol(this.getNeutronLoadBalancerListenerProtocol());
- }
- if (s.equals("protocol_port")) {
- ans.setNeutronLoadBalancerListenerProtocolPort(this.getNeutronLoadBalancerListenerProtocolPort());
- }
- if (s.equals("admin_state_up")) {
- ans.setLoadBalancerListenerAdminStateIsUp(loadBalancerListenerAdminStateIsUp);
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "default_pool_id":
+ ans.setNeutronLoadBalancerListenerDefaultPoolID(this.getNeutronLoadBalancerListenerDefaultPoolID());
+ break;
+ case "tenant_id":
+ ans.setLoadBalancerListenerTenantID(this.getLoadBalancerListenerTenantID());
+ break;
+ case "name":
+ ans.setLoadBalancerListenerName(this.getLoadBalancerListenerName());
+ break;
+ case "description":
+ ans.setLoadBalancerListenerDescription(this.getLoadBalancerListenerDescription());
+ break;
+ case "protocol":
+ ans.setNeutronLoadBalancerListenerProtocol(this.getNeutronLoadBalancerListenerProtocol());
+ break;
+ case "protocol_port":
+ ans.setNeutronLoadBalancerListenerProtocolPort(this.getNeutronLoadBalancerListenerProtocolPort());
+ break;
+ case "admin_state_up":
+ ans.setLoadBalancerListenerAdminStateIsUp(loadBalancerListenerAdminStateIsUp);
+ break;
}
}
return ans;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
/**
public NeutronLoadBalancerPool extractFields(List<String> fields) {
NeutronLoadBalancerPool ans = new NeutronLoadBalancerPool();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("tenant_id")) {
- ans.setLoadBalancerPoolTenantID(this.getLoadBalancerPoolTenantID());
- }
- if (s.equals("name")) {
- ans.setLoadBalancerPoolName(this.getLoadBalancerPoolName());
- }
- if(s.equals("description")) {
- ans.setLoadBalancerPoolDescription(this.getLoadBalancerPoolDescription());
- }
- if(s.equals("protocol")) {
- ans.setLoadBalancerPoolProtocol(this.getLoadBalancerPoolProtocol());
- }
- if (s.equals("lb_algorithm")) {
- ans.setLoadBalancerPoolLbAlgorithm(this.getLoadBalancerPoolLbAlgorithm());
- }
- if (s.equals("healthmonitor_id")) {
- ans.setNeutronLoadBalancerPoolHealthMonitorID(this.getNeutronLoadBalancerPoolHealthMonitorID());
- }
- if (s.equals("admin_state_up")) {
- ans.setLoadBalancerPoolAdminStateIsUp(loadBalancerPoolAdminStateIsUp);
- }
- if (s.equals("members")) {
- ans.setLoadBalancerPoolMembers(getLoadBalancerPoolMembers());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "tenant_id":
+ ans.setLoadBalancerPoolTenantID(this.getLoadBalancerPoolTenantID());
+ break;
+ case "name":
+ ans.setLoadBalancerPoolName(this.getLoadBalancerPoolName());
+ break;
+ case "description":
+ ans.setLoadBalancerPoolDescription(this.getLoadBalancerPoolDescription());
+ break;
+ case "protocol":
+ ans.setLoadBalancerPoolProtocol(this.getLoadBalancerPoolProtocol());
+ break;
+ case "lb_algorithm":
+ ans.setLoadBalancerPoolLbAlgorithm(this.getLoadBalancerPoolLbAlgorithm());
+ break;
+ case "healthmonitor_id":
+ ans.setNeutronLoadBalancerPoolHealthMonitorID(this.getNeutronLoadBalancerPoolHealthMonitorID());
+ break;
+ case "admin_state_up":
+ ans.setLoadBalancerPoolAdminStateIsUp(loadBalancerPoolAdminStateIsUp);
+ break;
+ case "members":
+ ans.setLoadBalancerPoolMembers(getLoadBalancerPoolMembers());
+ break;
}
}
return ans;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
@XmlRootElement
public NeutronLoadBalancerPoolMember extractFields(List<String> fields) {
NeutronLoadBalancerPoolMember ans = new NeutronLoadBalancerPoolMember();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("pool_id")) {
- ans.setPoolID(this.getPoolID());
- }
- if (s.equals("tenant_id")) {
- ans.setPoolMemberTenantID(this.getPoolMemberTenantID());
- }
- if (s.equals("address")) {
- ans.setPoolMemberAddress(this.getPoolMemberAddress());
- }
- if(s.equals("protocol_port")) {
- ans.setPoolMemberProtoPort(this.getPoolMemberProtoPort());
- }
- if (s.equals("admin_state_up")) {
- ans.setPoolMemberAdminStateIsUp(poolMemberAdminStateIsUp);
- }
- if(s.equals("weight")) {
- ans.setPoolMemberWeight(this.getPoolMemberWeight());
- }
- if(s.equals("subnet_id")) {
- ans.setPoolMemberSubnetID(this.getPoolMemberSubnetID());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "pool_id":
+ ans.setPoolID(this.getPoolID());
+ break;
+ case "tenant_id":
+ ans.setPoolMemberTenantID(this.getPoolMemberTenantID());
+ break;
+ case "address":
+ ans.setPoolMemberAddress(this.getPoolMemberAddress());
+ break;
+ case "protocol_port":
+ ans.setPoolMemberProtoPort(this.getPoolMemberProtoPort());
+ break;
+ case "admin_state_up":
+ ans.setPoolMemberAdminStateIsUp(poolMemberAdminStateIsUp);
+ break;
+ case "weight":
+ ans.setPoolMemberWeight(this.getPoolMemberWeight());
+ break;
+ case "subnet_id":
+ ans.setPoolMemberSubnetID(this.getPoolMemberSubnetID());
+ break;
}
}
return ans;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
}
public void initDefaults() {
- subnets = new ArrayList<String>();
+ subnets = new ArrayList<>();
if (status == null) {
status = "ACTIVE";
}
public NeutronNetwork extractFields(List<String> fields) {
NeutronNetwork ans = new NeutronNetwork();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setNetworkUUID(this.getNetworkUUID());
- }
- if (s.equals("name")) {
- ans.setNetworkName(this.getNetworkName());
- }
- if (s.equals("admin_state_up")) {
- ans.setAdminStateUp(adminStateUp);
- }
- if (s.equals("status")) {
- ans.setStatus(this.getStatus());
- }
- if (s.equals("subnets")) {
- List<String> subnetList = new ArrayList<String>();
- subnetList.addAll(this.getSubnets());
- ans.setSubnets(subnetList);
- }
- if (s.equals("shared")) {
- ans.setShared(shared);
- }
- if (s.equals("tenant_id")) {
- ans.setTenantID(this.getTenantID());
- }
- if (s.equals("external")) {
- ans.setRouterExternal(this.getRouterExternal());
- }
- if (s.equals("segmentation_id")) {
- ans.setProviderSegmentationID(this.getProviderSegmentationID());
- }
- if (s.equals("physical_network")) {
- ans.setProviderPhysicalNetwork(this.getProviderPhysicalNetwork());
- }
- if (s.equals("network_type")) {
- ans.setProviderNetworkType(this.getProviderNetworkType());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setNetworkUUID(this.getNetworkUUID());
+ break;
+ case "name":
+ ans.setNetworkName(this.getNetworkName());
+ break;
+ case "admin_state_up":
+ ans.setAdminStateUp(adminStateUp);
+ break;
+ case "status":
+ ans.setStatus(this.getStatus());
+ break;
+ case "subnets":
+ List<String> subnetList = new ArrayList<>();
+ subnetList.addAll(this.getSubnets());
+ ans.setSubnets(subnetList);
+ break;
+ case "shared":
+ ans.setShared(shared);
+ break;
+ case "tenant_id":
+ ans.setTenantID(this.getTenantID());
+ break;
+ case "external":
+ ans.setRouterExternal(this.getRouterExternal());
+ break;
+ case "segmentation_id":
+ ans.setProviderSegmentationID(this.getProviderSegmentationID());
+ break;
+ case "physical_network":
+ ans.setProviderPhysicalNetwork(this.getProviderPhysicalNetwork());
+ break;
+ case "network_type":
+ ans.setProviderNetworkType(this.getProviderNetworkType());
+ break;
}
}
return ans;
ans.setMacAddress(this.getMacAddress());
}
if ("fixed_ips".equals(field)) {
- ans.setFixedIPs(new ArrayList<Neutron_IPs>(this.getFixedIPs()));
+ ans.setFixedIPs(new ArrayList<>(this.getFixedIPs()));
}
if ("device_id".equals(field)) {
ans.setDeviceID(this.getDeviceID());
ans.setTenantID(this.getTenantID());
}
if ("security_groups".equals(field)) {
- ans.setSecurityGroups(new ArrayList<NeutronSecurityGroup>(this.getSecurityGroups()));
+ ans.setSecurityGroups(new ArrayList<>(this.getSecurityGroups()));
}
}
return ans;
status = "ACTIVE";
}
if (fixedIPs == null) {
- fixedIPs = new ArrayList<Neutron_IPs>();
+ fixedIPs = new ArrayList<>();
}
}
import java.io.Serializable;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
Map<String, NeutronRouter_Interface> interfaces;
public NeutronRouter() {
- interfaces = new HashMap<String, NeutronRouter_Interface>();
+ interfaces = new HashMap<>();
}
public String getID() { return routerUUID; }
*/
public NeutronRouter extractFields(List<String> fields) {
NeutronRouter ans = new NeutronRouter();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setRouterUUID(this.getRouterUUID());
- }
- if (s.equals("name")) {
- ans.setName(this.getName());
- }
- if (s.equals("admin_state_up")) {
- ans.setAdminStateUp(this.getAdminStateUp());
- }
- if (s.equals("status")) {
- ans.setStatus(this.getStatus());
- }
- if (s.equals("tenant_id")) {
- ans.setTenantID(this.getTenantID());
- }
- if (s.equals("external_gateway_info")) {
- ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
- }
- if (s.equals("distributed")) {
- ans.setDistributed(this.getDistributed());
- }
- if (s.equals("gw_port_id")) {
- ans.setGatewayPortId(this.getGatewayPortId());
- }
- if (s.equals("routes")){
- ans.setRoutes(this.getRoutes());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setRouterUUID(this.getRouterUUID());
+ break;
+ case "name":
+ ans.setName(this.getName());
+ break;
+ case "admin_state_up":
+ ans.setAdminStateUp(this.getAdminStateUp());
+ break;
+ case "status":
+ ans.setStatus(this.getStatus());
+ break;
+ case "tenant_id":
+ ans.setTenantID(this.getTenantID());
+ break;
+ case "external_gateway_info":
+ ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
+ break;
+ case "distributed":
+ ans.setDistributed(this.getDistributed());
+ break;
+ case "gw_port_id":
+ ans.setGatewayPortId(this.getGatewayPortId());
+ break;
+ case "routes":
+ ans.setRoutes(this.getRoutes());
+ break;
}
}
return ans;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
List<NeutronSecurityRule> neutronSecurityRule;
public NeutronSecurityGroup() {
- neutronSecurityRule = new ArrayList<NeutronSecurityRule>();
+ neutronSecurityRule = new ArrayList<>();
}
public NeutronSecurityGroup extractFields(List<String> fields) {
NeutronSecurityGroup ans = new NeutronSecurityGroup ();
- Iterator<String> i = fields.iterator ();
- while (i.hasNext ()) {
- String s = i.next ();
- if (s.equals ("id")) {
- ans.setID (this.getID ());
- }
- if (s.equals ("name")) {
- ans.setSecurityGroupName (this.getSecurityGroupName ());
- }
- if (s.equals ("description")) {
- ans.setSecurityGroupDescription (this.getSecurityGroupDescription ());
- }
- if (s.equals ("tenant_id")) {
- ans.setSecurityGroupTenantID (this.getSecurityGroupTenantID ());
- }
- if (s.equals ("security_group_rules")) {
- ans.setSecurityRules (this.getSecurityRules ());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "name":
+ ans.setSecurityGroupName(this.getSecurityGroupName());
+ break;
+ case "description":
+ ans.setSecurityGroupDescription(this.getSecurityGroupDescription());
+ break;
+ case "tenant_id":
+ ans.setSecurityGroupTenantID(this.getSecurityGroupTenantID());
+ break;
+ case "security_group_rules":
+ ans.setSecurityRules(this.getSecurityRules());
+ break;
}
}
return ans;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
/**
public NeutronSecurityRule extractFields(List<String> fields) {
NeutronSecurityRule ans = new NeutronSecurityRule();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("direction")) {
- ans.setSecurityRuleDirection(this.getSecurityRuleDirection());
- }
- if (s.equals("protocol")) {
- ans.setSecurityRuleProtocol(this.getSecurityRuleProtocol());
- }
- if (s.equals("port_range_min")) {
- ans.setSecurityRulePortMin(this.getSecurityRulePortMin());
- }
- if (s.equals("port_range_max")) {
- ans.setSecurityRulePortMax(this.getSecurityRulePortMax());
- }
- if (s.equals("ethertype")) {
- ans.setSecurityRuleEthertype(this.getSecurityRuleEthertype());
- }
- if (s.equals("remote_ip_prefix")) {
- ans.setSecurityRuleRemoteIpPrefix(this.getSecurityRuleRemoteIpPrefix());
- }
- if (s.equals("remote_group_id")) {
- ans.setSecurityRemoteGroupID(this.getSecurityRemoteGroupID());
- }
- if (s.equals("security_group_id")) {
- ans.setSecurityRuleGroupID(this.getSecurityRuleGroupID());
- }
- if (s.equals("tenant_id")) {
- ans.setSecurityRuleTenantID(this.getSecurityRuleTenantID());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "direction":
+ ans.setSecurityRuleDirection(this.getSecurityRuleDirection());
+ break;
+ case "protocol":
+ ans.setSecurityRuleProtocol(this.getSecurityRuleProtocol());
+ break;
+ case "port_range_min":
+ ans.setSecurityRulePortMin(this.getSecurityRulePortMin());
+ break;
+ case "port_range_max":
+ ans.setSecurityRulePortMax(this.getSecurityRulePortMax());
+ break;
+ case "ethertype":
+ ans.setSecurityRuleEthertype(this.getSecurityRuleEthertype());
+ break;
+ case "remote_ip_prefix":
+ ans.setSecurityRuleRemoteIpPrefix(this.getSecurityRuleRemoteIpPrefix());
+ break;
+ case "remote_group_id":
+ ans.setSecurityRemoteGroupID(this.getSecurityRemoteGroupID());
+ break;
+ case "security_group_id":
+ ans.setSecurityRuleGroupID(this.getSecurityRuleGroupID());
+ break;
+ case "tenant_id":
+ ans.setSecurityRuleTenantID(this.getSecurityRuleTenantID());
+ break;
}
}
return ans;
List<NeutronPort> myPorts;
public NeutronSubnet() {
- myPorts = new ArrayList<NeutronPort>();
+ myPorts = new ArrayList<>();
}
// @deprecated - will be removed in Boron
public NeutronSubnet extractFields(List<String> fields) {
NeutronSubnet ans = new NeutronSubnet();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setSubnetUUID(this.getSubnetUUID());
- }
- if (s.equals("network_id")) {
- ans.setNetworkUUID(this.getNetworkUUID());
- }
- if (s.equals("name")) {
- ans.setName(this.getName());
- }
- if (s.equals("ip_version")) {
- ans.setIpVersion(this.getIpVersion());
- }
- if (s.equals("cidr")) {
- ans.setCidr(this.getCidr());
- }
- if (s.equals("gateway_ip")) {
- ans.setGatewayIP(this.getGatewayIP());
- }
- if (s.equals("dns_nameservers")) {
- List<String> nsList = new ArrayList<String>();
- nsList.addAll(this.getDnsNameservers());
- ans.setDnsNameservers(nsList);
- }
- if (s.equals("allocation_pools")) {
- List<NeutronSubnetIPAllocationPool> aPools = new ArrayList<NeutronSubnetIPAllocationPool>();
- aPools.addAll(this.getAllocationPools());
- ans.setAllocationPools(aPools);
- }
- if (s.equals("host_routes")) {
- List<NeutronSubnet_HostRoute> hRoutes = new ArrayList<NeutronSubnet_HostRoute>();
- hRoutes.addAll(this.getHostRoutes());
- ans.setHostRoutes(hRoutes);
- }
- if (s.equals("enable_dhcp")) {
- ans.setEnableDHCP(this.getEnableDHCP());
- }
- if (s.equals("tenant_id")) {
- ans.setTenantID(this.getTenantID());
- }
- if (s.equals("ipv6_address_mode")) {
- ans.setIpV6AddressMode(this.getIpV6AddressMode());
- }
- if (s.equals("ipv6_ra_mode")) {
- ans.setIpV6RaMode(this.getIpV6RaMode());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setSubnetUUID(this.getSubnetUUID());
+ break;
+ case "network_id":
+ ans.setNetworkUUID(this.getNetworkUUID());
+ break;
+ case "name":
+ ans.setName(this.getName());
+ break;
+ case "ip_version":
+ ans.setIpVersion(this.getIpVersion());
+ break;
+ case "cidr":
+ ans.setCidr(this.getCidr());
+ break;
+ case "gateway_ip":
+ ans.setGatewayIP(this.getGatewayIP());
+ break;
+ case "dns_nameservers":
+ List<String> nsList = new ArrayList<>();
+ nsList.addAll(this.getDnsNameservers());
+ ans.setDnsNameservers(nsList);
+ break;
+ case "allocation_pools":
+ List<NeutronSubnetIPAllocationPool> aPools = new ArrayList<>();
+ aPools.addAll(this.getAllocationPools());
+ ans.setAllocationPools(aPools);
+ break;
+ case "host_routes":
+ List<NeutronSubnet_HostRoute> hRoutes = new ArrayList<>();
+ hRoutes.addAll(this.getHostRoutes());
+ ans.setHostRoutes(hRoutes);
+ break;
+ case "enable_dhcp":
+ ans.setEnableDHCP(this.getEnableDHCP());
+ break;
+ case "tenant_id":
+ ans.setTenantID(this.getTenantID());
+ break;
+ case "ipv6_address_mode":
+ ans.setIpV6AddressMode(this.getIpV6AddressMode());
+ break;
+ case "ipv6_ra_mode":
+ ans.setIpV6RaMode(this.getIpV6RaMode());
+ break;
}
}
return ans;
// @deprecated - will be removed in Boron
public List<NeutronPort> getPortsInSubnet(String ignore) {
- List<NeutronPort> answer = new ArrayList<NeutronPort>();
+ List<NeutronPort> answer = new ArrayList<>();
for (NeutronPort port : myPorts) {
if (!port.getDeviceOwner().equalsIgnoreCase(ignore)) {
answer.add(port);
int length = Integer.parseInt(parts[1]);
//TODO?: limit check on length
// convert to byte array
- byte[] addrBytes = ((Inet6Address) InetAddress.getByName(parts[0])).getAddress();
+ byte[] addrBytes = InetAddress.getByName(parts[0]).getAddress();
int i;
for (i = length; i < IPV6_LENGTH; i++) {
if (((((int) addrBytes[i/IPV6_LENGTH_BYTES]) & IPV6_LSB_MASK) & (1 << (IPV6_BYTE_OFFSET-(i%IPV6_LENGTH_BYTES)))) != 0) {
* or assigning a gateway IP)
*/
public boolean gatewayIP_Pool_overlap() {
- Iterator<NeutronSubnetIPAllocationPool> i = allocationPools.iterator();
- while (i.hasNext()) {
- NeutronSubnetIPAllocationPool pool = i.next();
+ for (NeutronSubnetIPAllocationPool pool : allocationPools) {
if (ipVersion == IPV4_VERSION && pool.contains(gatewayIP)) {
return true;
}
if (ipVersion == null) {
ipVersion = IPV4_VERSION;
}
- dnsNameservers = new ArrayList<String>();
+ dnsNameservers = new ArrayList<>();
if (hostRoutes == null) {
- hostRoutes = new ArrayList<NeutronSubnet_HostRoute>();
+ hostRoutes = new ArrayList<>();
}
if (allocationPools == null) {
- allocationPools = new ArrayList<NeutronSubnetIPAllocationPool>();
+ allocationPools = new ArrayList<>();
if (ipVersion == IPV4_VERSION) {
try {
SubnetUtils util = new SubnetUtils(cidr);
String[] parts = cidr.split("/");
try {
int length = Integer.parseInt(parts[1]);
- byte[] cidrBytes = ((Inet6Address) InetAddress.getByName(parts[0])).getAddress();
- byte[] ipBytes = ((Inet6Address) InetAddress.getByName(ipAddress)).getAddress();
+ byte[] cidrBytes = InetAddress.getByName(parts[0]).getAddress();
+ byte[] ipBytes = InetAddress.getByName(ipAddress).getAddress();
int i;
for (i = 0; i < length; i++) {
if (((((int) cidrBytes[i/IPV6_LENGTH_BYTES]) & IPV6_LSB_MASK) & (1 << (IPV6_BYTE_OFFSET-(i%IPV6_LENGTH_BYTES)))) !=
*/
public String getLowAddr() {
String ans = null;
- Iterator<NeutronSubnetIPAllocationPool> i = allocationPools.iterator();
- while (i.hasNext()) {
- NeutronSubnetIPAllocationPool pool = i.next();
+ for (NeutronSubnetIPAllocationPool pool : allocationPools) {
if (ans == null) {
ans = pool.getPoolStart();
- }
- else {
+ } else {
if (ipVersion == IPV4_VERSION &&
- NeutronSubnetIPAllocationPool.convert(pool.getPoolStart()) <
- NeutronSubnetIPAllocationPool.convert(ans)) {
+ NeutronSubnetIPAllocationPool.convert(pool.getPoolStart()) <
+ NeutronSubnetIPAllocationPool.convert(ans)) {
ans = pool.getPoolStart();
}
if (ipVersion == IPV6_VERSION &&
- NeutronSubnetIPAllocationPool.convertV6(pool.getPoolStart()).compareTo(NeutronSubnetIPAllocationPool.convertV6(ans)) < 0) {
+ NeutronSubnetIPAllocationPool.convertV6(pool.getPoolStart()).compareTo(
+ NeutronSubnetIPAllocationPool.convertV6(ans)) < 0) {
ans = pool.getPoolStart();
}
- }
+ }
}
return ans;
}
return BigInteger.ZERO;
}
try {
- return new BigInteger(((Inet6Address) InetAddress.getByName(inputString)).getAddress());
+ return new BigInteger(InetAddress.getByName(inputString).getAddress());
} catch (Exception e) {
LOGGER.error("convertV6 error", e);
return BigInteger.ZERO;
* the other ranging from parameter+1 to high
*/
public List<NeutronSubnetIPAllocationPool> splitPool(String ipAddress) {
- List<NeutronSubnetIPAllocationPool> ans = new ArrayList<NeutronSubnetIPAllocationPool>();
+ List<NeutronSubnetIPAllocationPool> ans = new ArrayList<>();
long gIP = NeutronSubnetIPAllocationPool.convert(ipAddress);
long sIP = NeutronSubnetIPAllocationPool.convert(poolStart);
long eIP = NeutronSubnetIPAllocationPool.convert(poolEnd);
* If the pool is a single address, return null
*/
public List<NeutronSubnetIPAllocationPool> splitPoolV6(String ipAddress) {
- List<NeutronSubnetIPAllocationPool> ans = new ArrayList<NeutronSubnetIPAllocationPool>();
+ List<NeutronSubnetIPAllocationPool> ans = new ArrayList<>();
BigInteger gIP = NeutronSubnetIPAllocationPool.convertV6(ipAddress);
BigInteger sIP = NeutronSubnetIPAllocationPool.convertV6(poolStart);
BigInteger eIP = NeutronSubnetIPAllocationPool.convertV6(poolEnd);
@Override
public List<NeutronFloatingIP> getAllFloatingIPs() {
- Set<NeutronFloatingIP> allIPs = new HashSet<NeutronFloatingIP>();
+ Set<NeutronFloatingIP> allIPs = new HashSet<>();
Floatingips fips = readMd(createInstanceIdentifier());
if (fips != null) {
for (Floatingip fip: fips.getFloatingip()) {
}
}
LOGGER.debug("Exiting getAllFloatingIPs, Found {} FloatingIPs", allIPs.size());
- List<NeutronFloatingIP> ans = new ArrayList<NeutronFloatingIP>();
+ List<NeutronFloatingIP> ans = new ArrayList<>();
ans.addAll(allIPs);
return ans;
}
*/
public class NeutronLoadBalancerInterface extends AbstractNeutronInterface<Loadbalancer, NeutronLoadBalancer> implements INeutronLoadBalancerCRUD {
private static final Logger LOGGER = LoggerFactory.getLogger(NeutronLoadBalancerInterface.class);
- private ConcurrentMap<String, NeutronLoadBalancer> loadBalancerDB = new ConcurrentHashMap<String, NeutronLoadBalancer>();
+ private ConcurrentMap<String, NeutronLoadBalancer> loadBalancerDB = new ConcurrentHashMap<>();
NeutronLoadBalancerInterface(ProviderContext providerContext) {
@Override
public List<NeutronLoadBalancer> getAllNeutronLoadBalancers() {
- Set<NeutronLoadBalancer> allLoadBalancers = new HashSet<NeutronLoadBalancer>();
+ Set<NeutronLoadBalancer> allLoadBalancers = new HashSet<>();
for (Entry<String, NeutronLoadBalancer> entry : loadBalancerDB.entrySet()) {
NeutronLoadBalancer loadBalancer = entry.getValue();
allLoadBalancers.add(loadBalancer);
}
LOGGER.debug("Exiting getLoadBalancers, Found {} OpenStackLoadBalancer", allLoadBalancers.size());
- List<NeutronLoadBalancer> ans = new ArrayList<NeutronLoadBalancer>();
+ List<NeutronLoadBalancer> ans = new ArrayList<>();
ans.addAll(allLoadBalancers);
return ans;
}
public class NeutronLoadBalancerPoolInterface extends AbstractNeutronInterface<Pool, NeutronLoadBalancerPool> implements INeutronLoadBalancerPoolCRUD {
private static final Logger LOGGER = LoggerFactory.getLogger(NeutronLoadBalancerPoolInterface.class);
- private ConcurrentMap<String, NeutronLoadBalancerPool> loadBalancerPoolDB = new ConcurrentHashMap<String, NeutronLoadBalancerPool>();
+ private ConcurrentMap<String, NeutronLoadBalancerPool> loadBalancerPoolDB = new ConcurrentHashMap<>();
private static final ImmutableBiMap<Class<? extends ProtocolBase>,String> PROTOCOL_MAP
= new ImmutableBiMap.Builder<Class<? extends ProtocolBase>,String>()
@Override
public List<NeutronLoadBalancerPool> getAllNeutronLoadBalancerPools() {
- Set<NeutronLoadBalancerPool> allLoadBalancerPools = new HashSet<NeutronLoadBalancerPool>();
+ Set<NeutronLoadBalancerPool> allLoadBalancerPools = new HashSet<>();
for (Entry<String, NeutronLoadBalancerPool> entry : loadBalancerPoolDB.entrySet()) {
NeutronLoadBalancerPool loadBalancerPool = entry.getValue();
allLoadBalancerPools.add(loadBalancerPool);
}
LOGGER.debug("Exiting getLoadBalancerPools, Found {} OpenStackLoadBalancerPool", allLoadBalancerPools.size());
- List<NeutronLoadBalancerPool> ans = new ArrayList<NeutronLoadBalancerPool>();
+ List<NeutronLoadBalancerPool> ans = new ArrayList<>();
ans.addAll(allLoadBalancerPools);
return ans;
}
poolBuilder.setLbAlgorithm(pool.getLoadBalancerPoolLbAlgorithm());
}
if (pool.getLoadBalancerPoolListeners() != null) {
- List<Uuid> listListener = new ArrayList<Uuid>();
+ List<Uuid> listListener = new ArrayList<>();
for (Neutron_ID neutron_id : pool.getLoadBalancerPoolListeners()) {
listListener.add(toUuid(neutron_id.getID()));
}
if (pool.getLoadBalancerPoolProtocol() != null) {
ImmutableBiMap<String, Class<? extends ProtocolBase>> mapper =
PROTOCOL_MAP.inverse();
- poolBuilder.setProtocol((Class<? extends ProtocolBase>) mapper.get(pool.getLoadBalancerPoolProtocol()));
+ poolBuilder.setProtocol(mapper.get(pool.getLoadBalancerPoolProtocol()));
}
if (pool.getLoadBalancerPoolSessionPersistence() != null) {
NeutronLoadBalancer_SessionPersistence sessionPersistence = pool.getLoadBalancerPoolSessionPersistence();
@Override
public List<NeutronNetwork> getAllNetworks() {
- Set<NeutronNetwork> allNetworks = new HashSet<NeutronNetwork>();
+ Set<NeutronNetwork> allNetworks = new HashSet<>();
Networks networks = readMd(createInstanceIdentifier());
if (networks != null) {
for (Network network: networks.getNetwork()) {
}
}
LOGGER.debug("Exiting getAllNetworks, Found {} OpenStackNetworks", allNetworks.size());
- List<NeutronNetwork> ans = new ArrayList<NeutronNetwork>();
+ List<NeutronNetwork> ans = new ArrayList<>();
ans.addAll(allNetworks);
return ans;
}
result.setShared(network.isShared());
result.setStatus(network.getStatus());
if (network.getSubnets() != null) {
- List<String> neutronSubnets = new ArrayList<String>();
+ List<String> neutronSubnets = new ArrayList<>();
for( Uuid subnet : network.getSubnets()) {
neutronSubnets.add(subnet.getValue());
}
result.setProviderPhysicalNetwork(providerExtension.getPhysicalNetwork());
result.setProviderSegmentationID(providerExtension.getSegmentationId());
result.setProviderNetworkType(NETWORK_MAP.get(providerExtension.getNetworkType()));
- List<NeutronNetwork_Segment> segments = new ArrayList<NeutronNetwork_Segment>();
+ List<NeutronNetwork_Segment> segments = new ArrayList<>();
if (providerExtension.getSegments() != null) {
for (Segments segment: providerExtension.getSegments()) {
NeutronNetwork_Segment neutronSegment = new NeutronNetwork_Segment();
if (network.getProviderNetworkType() != null) {
ImmutableBiMap<String, Class<? extends NetworkTypeBase>> mapper =
NETWORK_MAP.inverse();
- providerExtensionBuilder.setNetworkType((Class<? extends NetworkTypeBase>) mapper.get(network.getProviderNetworkType()));
+ providerExtensionBuilder.setNetworkType(mapper.get(network.getProviderNetworkType()));
}
if (network.getSegments() != null) {
- List<Segments> segments = new ArrayList<Segments>();
+ List<Segments> segments = new ArrayList<>();
long count = 0;
for( NeutronNetwork_Segment segment : network.getSegments()) {
count++;
if (segment.getProviderNetworkType() != null) {
ImmutableBiMap<String, Class<? extends NetworkTypeBase>> mapper =
NETWORK_MAP.inverse();
- segmentsBuilder.setNetworkType((Class<? extends NetworkTypeBase>) mapper.get(segment.getProviderNetworkType()));
+ segmentsBuilder.setNetworkType(mapper.get(segment.getProviderNetworkType()));
}
- segmentsBuilder.setSegmentationIndex(Long.valueOf(count));
+ segmentsBuilder.setSegmentationIndex(count);
segments.add(segmentsBuilder.build());
}
providerExtensionBuilder.setSegments(segments);
networkBuilder.setStatus(network.getStatus());
}
if (network.getSubnets() != null) {
- List<Uuid> subnets = new ArrayList<Uuid>();
+ List<Uuid> subnets = new ArrayList<>();
for( String subnet : network.getSubnets()) {
subnets.add(toUuid(subnet));
}
@Override
public List<NeutronPort> getAllPorts() {
- Set<NeutronPort> allPorts = new HashSet<NeutronPort>();
+ Set<NeutronPort> allPorts = new HashSet<>();
Ports ports = readMd(createInstanceIdentifier());
if (ports != null) {
for (Port port : ports.getPort()) {
}
}
LOGGER.debug("Exiting getAllPorts, Found {} OpenStackPorts", allPorts.size());
- List<NeutronPort> ans = new ArrayList<NeutronPort>();
+ List<NeutronPort> ans = new ArrayList<>();
ans.addAll(allPorts);
return ans;
}
PortBindingExtension binding = port.getAugmentation(PortBindingExtension.class);
result.setBindinghostID(binding.getHostId());
if (binding.getVifDetails() != null) {
- List<NeutronPort_VIFDetail> details = new ArrayList<NeutronPort_VIFDetail>();
+ List<NeutronPort_VIFDetail> details = new ArrayList<>();
for (VifDetails vifDetail : binding.getVifDetails()) {
NeutronPort_VIFDetail detail = new NeutronPort_VIFDetail();
detail.setPortFilter(vifDetail.isPortFilter());
NeutronPort result = new NeutronPort();
result.setAdminStateUp(port.isAdminStateUp());
if (port.getAllowedAddressPairs() != null) {
- List<NeutronPort_AllowedAddressPairs> pairs = new ArrayList<NeutronPort_AllowedAddressPairs>();
+ List<NeutronPort_AllowedAddressPairs> pairs = new ArrayList<>();
for (AllowedAddressPairs mdPair : port.getAllowedAddressPairs()) {
NeutronPort_AllowedAddressPairs pair = new NeutronPort_AllowedAddressPairs();
pair.setIpAddress(mdPair.getIpAddress());
result.setDeviceID(port.getDeviceId());
result.setDeviceOwner(port.getDeviceOwner());
if (port.getExtraDhcpOpts() != null) {
- List<NeutronPort_ExtraDHCPOption> options = new ArrayList<NeutronPort_ExtraDHCPOption>();
+ List<NeutronPort_ExtraDHCPOption> options = new ArrayList<>();
for (ExtraDhcpOpts opt : port.getExtraDhcpOpts()) {
NeutronPort_ExtraDHCPOption arg = new NeutronPort_ExtraDHCPOption();
arg.setName(opt.getOptName());
result.setExtraDHCPOptions(options);
}
if (port.getFixedIps() != null) {
- List<Neutron_IPs> ips = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> ips = new ArrayList<>();
for (FixedIps mdIP : port.getFixedIps()) {
Neutron_IPs ip = new Neutron_IPs();
ip.setIpAddress(String.valueOf(mdIP.getIpAddress().getValue()));
result.setName(port.getName());
result.setNetworkUUID(String.valueOf(port.getNetworkId().getValue()));
if (port.getSecurityGroups() != null) {
- Set<NeutronSecurityGroup> allGroups = new HashSet<NeutronSecurityGroup>();
+ Set<NeutronSecurityGroup> allGroups = new HashSet<>();
NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces().fetchINeutronSecurityGroupCRUD(this);
INeutronSecurityGroupCRUD sgIf = interfaces.getSecurityGroupInterface();
for (Uuid sgUuid : port.getSecurityGroups()) {
- allGroups.add(sgIf.getNeutronSecurityGroup(sgUuid.getValue()));
+ NeutronSecurityGroup secGroup = sgIf.getNeutronSecurityGroup(sgUuid.getValue());
+ if (secGroup != null) {
+ allGroups.add(sgIf.getNeutronSecurityGroup(sgUuid.getValue()));
+ }
}
- List<NeutronSecurityGroup> groups = new ArrayList<NeutronSecurityGroup>();
+ List<NeutronSecurityGroup> groups = new ArrayList<>();
groups.addAll(allGroups);
result.setSecurityGroups(groups);
}
bindingBuilder.setHostId(neutronPort.getBindinghostID());
}
if (neutronPort.getVIFDetail() != null) {
- List<VifDetails> listVifDetail = new ArrayList<VifDetails>();
+ List<VifDetails> listVifDetail = new ArrayList<>();
for (NeutronPort_VIFDetail detail: neutronPort.getVIFDetail()) {
VifDetailsBuilder vifDetailsBuilder = new VifDetailsBuilder();
if (detail.getPortFilter() != null) {
bindingBuilder.build());
portBuilder.setAdminStateUp(neutronPort.isAdminStateUp());
if(neutronPort.getAllowedAddressPairs() != null) {
- List<AllowedAddressPairs> listAllowedAddressPairs = new ArrayList<AllowedAddressPairs>();
+ List<AllowedAddressPairs> listAllowedAddressPairs = new ArrayList<>();
for (NeutronPort_AllowedAddressPairs allowedAddressPairs : neutronPort.getAllowedAddressPairs()) {
AllowedAddressPairsBuilder allowedAddressPairsBuilder = new AllowedAddressPairsBuilder();
allowedAddressPairsBuilder.setIpAddress(allowedAddressPairs.getIpAddress());
portBuilder.setDeviceOwner(neutronPort.getDeviceOwner());
}
if (neutronPort.getExtraDHCPOptions() != null) {
- List<ExtraDhcpOpts> listExtraDHCPOptions = new ArrayList<ExtraDhcpOpts>();
+ List<ExtraDhcpOpts> listExtraDHCPOptions = new ArrayList<>();
for (NeutronPort_ExtraDHCPOption extraDHCPOption : neutronPort.getExtraDHCPOptions()) {
ExtraDhcpOptsBuilder extraDHCPOptsBuilder = new ExtraDhcpOptsBuilder();
extraDHCPOptsBuilder.setOptName(extraDHCPOption.getName());
portBuilder.setExtraDhcpOpts(listExtraDHCPOptions);
}
if (neutronPort.getFixedIPs() != null) {
- List<FixedIps> listNeutronIPs = new ArrayList<FixedIps>();
+ List<FixedIps> listNeutronIPs = new ArrayList<>();
for (Neutron_IPs neutron_IPs : neutronPort.getFixedIPs()) {
FixedIpsBuilder fixedIpsBuilder = new FixedIpsBuilder();
fixedIpsBuilder.setIpAddress(new IpAddress(neutron_IPs.getIpAddress().toCharArray()));
portBuilder.setNetworkId(toUuid(neutronPort.getNetworkUUID()));
}
if (neutronPort.getSecurityGroups() != null) {
- List<Uuid> listSecurityGroups = new ArrayList<Uuid>();
+ List<Uuid> listSecurityGroups = new ArrayList<>();
for (NeutronSecurityGroup neutronSecurityGroup : neutronPort.getSecurityGroups()) {
listSecurityGroups.add(toUuid(neutronSecurityGroup.getID()));
}
@Override
public List<NeutronRouter> getAllRouters() {
- Set<NeutronRouter> allRouters = new HashSet<NeutronRouter>();
+ Set<NeutronRouter> allRouters = new HashSet<>();
Routers routers = readMd(createInstanceIdentifier());
if (routers != null) {
for (Router router: routers.getRouter()) {
}
}
LOGGER.debug("Exiting getAllRouters, Found {} Routers", allRouters.size());
- List<NeutronRouter> ans = new ArrayList<NeutronRouter>();
+ List<NeutronRouter> ans = new ArrayList<>();
ans.addAll(allRouters);
return ans;
}
routerBuilder.setAdminStateUp(router.getAdminStateUp());
routerBuilder.setDistributed(router.getDistributed());
if (router.getRoutes() != null) {
- List<String> routes = new ArrayList<String>();
+ List<String> routes = new ArrayList<>();
for (String route : router.getRoutes()) {
routes.add(route);
}
}
if (router.getExternalGatewayInfo() != null) {
ExternalGatewayInfo externalGatewayInfo = null;
- List<NeutronRouter_NetworkReference> neutronRouter_NetworkReferences = new ArrayList<NeutronRouter_NetworkReference>();
+ List<NeutronRouter_NetworkReference> neutronRouter_NetworkReferences = new ArrayList<>();
neutronRouter_NetworkReferences.add(router.getExternalGatewayInfo());
for (NeutronRouter_NetworkReference externalGatewayInfos : neutronRouter_NetworkReferences) {
ExternalGatewayInfoBuilder builder = new ExternalGatewayInfoBuilder();
builder.setEnableSnat(externalGatewayInfos.getEnableSNAT());
builder.setExternalNetworkId(toUuid(externalGatewayInfos.getNetworkID()));
if (externalGatewayInfos.getExternalFixedIPs() != null) {
- List<ExternalFixedIps> externalFixedIps = new ArrayList<ExternalFixedIps>();
+ List<ExternalFixedIps> externalFixedIps = new ArrayList<>();
for (Neutron_IPs eIP : externalGatewayInfos.getExternalFixedIPs()) {
ExternalFixedIpsBuilder eFixedIpBuilder = new ExternalFixedIpsBuilder();
eFixedIpBuilder.setIpAddress(new IpAddress(eIP.getIpAddress().toCharArray()));
routerBuilder.setExternalGatewayInfo(externalGatewayInfo);
}
if (router.getInterfaces() != null) {
- Map<String, NeutronRouter_Interface> mapInterfaces = new HashMap<String, NeutronRouter_Interface>();
- List<Interfaces> interfaces = new ArrayList<Interfaces>();
+ Map<String, NeutronRouter_Interface> mapInterfaces = new HashMap<>();
+ List<Interfaces> interfaces = new ArrayList<>();
for (Entry<String, NeutronRouter_Interface> entry : mapInterfaces.entrySet()) {
interfaces.add((Interfaces) entry.getValue());
}
result.setGatewayPortId(String.valueOf(router.getGatewayPortId().getValue()));
}
if (router.getRoutes() != null) {
- List<String> routes = new ArrayList<String>();
+ List<String> routes = new ArrayList<>();
for (String route : router.getRoutes()) {
routes.add(route);
}
extGwInfo.setNetworkID(String.valueOf(router.getExternalGatewayInfo().getExternalNetworkId().getValue()));
extGwInfo.setEnableSNAT(router.getExternalGatewayInfo().isEnableSnat());
if (router.getExternalGatewayInfo().getExternalFixedIps() != null) {
- List<Neutron_IPs> fixedIPs = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> fixedIPs = new ArrayList<>();
for (ExternalFixedIps mdFixedIP : router.getExternalGatewayInfo().getExternalFixedIps()) {
Neutron_IPs fixedIP = new Neutron_IPs();
fixedIP.setSubnetUUID(String.valueOf(mdFixedIP.getSubnetId().getValue()));
}
if (router.getInterfaces() != null) {
- Map<String, NeutronRouter_Interface> interfaces = new HashMap<String, NeutronRouter_Interface>();
+ Map<String, NeutronRouter_Interface> interfaces = new HashMap<>();
for (Interfaces mdInterface : router.getInterfaces()) {
NeutronRouter_Interface pojoInterface = new NeutronRouter_Interface();
String id = String.valueOf(mdInterface.getUuid().getValue());
@Override
public List<NeutronSecurityGroup> getAllNeutronSecurityGroups() {
- Set<NeutronSecurityGroup> allSecurityGroups = new HashSet<NeutronSecurityGroup>();
+ Set<NeutronSecurityGroup> allSecurityGroups = new HashSet<>();
SecurityGroups groups = readMd(createInstanceIdentifier());
if (groups != null) {
for (SecurityGroup group: groups.getSecurityGroup()) {
}
}
LOGGER.debug("Exiting getSecurityGroups, Found {} OpenStackSecurityGroup", allSecurityGroups.size());
- List<NeutronSecurityGroup> ans = new ArrayList<NeutronSecurityGroup>();
+ List<NeutronSecurityGroup> ans = new ArrayList<>();
ans.addAll(allSecurityGroups);
return ans;
}
.fetchINeutronSecurityRuleCRUD(this);
INeutronSecurityRuleCRUD srCrud = interfaces.getSecurityRuleInterface();
- List<NeutronSecurityRule> rules = new ArrayList<NeutronSecurityRule>();
+ List<NeutronSecurityRule> rules = new ArrayList<>();
for (Uuid uuid: group.getSecurityRules()) {
rules.add(srCrud.getNeutronSecurityRule(uuid.getValue()));
}
securityGroupBuilder.setTenantId(toUuid(securityGroup.getSecurityGroupTenantID()));
}
if (securityGroup.getSecurityRules() != null) {
- List<Uuid> neutronSecurityRule = new ArrayList<Uuid>();
+ List<Uuid> neutronSecurityRule = new ArrayList<>();
for (NeutronSecurityRule securityRule : securityGroup.getSecurityRules()) {
if (securityRule.getID() != null) {
neutronSecurityRule.add(toUuid(securityRule.getID()));
INeutronSecurityGroupCRUD sgCrud = interfaces.getSecurityGroupInterface();
NeutronSecurityGroup sg = sgCrud.getNeutronSecurityGroup(input.getSecurityRuleGroupID());
if(sg != null && sg.getSecurityRules() != null) {
- List<NeutronSecurityRule> toRemove = new ArrayList<NeutronSecurityRule>();
+ List<NeutronSecurityRule> toRemove = new ArrayList<>();
for(NeutronSecurityRule sgr :sg.getSecurityRules()) {
if(sgr.getID() != null && sgr.getID().equals(input.getID())) {
toRemove.add(sgr);
@Override
public List<NeutronSecurityRule> getAllNeutronSecurityRules() {
- Set<NeutronSecurityRule> allSecurityRules = new HashSet<NeutronSecurityRule>();
+ Set<NeutronSecurityRule> allSecurityRules = new HashSet<>();
SecurityRules rules = readMd(createInstanceIdentifier());
if (rules != null) {
for (SecurityRule rule: rules.getSecurityRule()) {
}
}
LOGGER.debug("Exiting getSecurityRule, Found {} OpenStackSecurityRule", allSecurityRules.size());
- List<NeutronSecurityRule> ans = new ArrayList<NeutronSecurityRule>();
+ List<NeutronSecurityRule> ans = new ArrayList<>();
ans.addAll(allSecurityRules);
return ans;
}
if (securityRule.getSecurityRuleDirection() != null) {
ImmutableBiMap<String, Class<? extends DirectionBase>> mapper =
DIRECTION_MAP.inverse();
- securityRuleBuilder.setDirection((Class<? extends DirectionBase>) mapper.get(securityRule.getSecurityRuleDirection()));
+ securityRuleBuilder.setDirection(mapper.get(securityRule.getSecurityRuleDirection()));
}
if (securityRule.getSecurityRuleGroupID() != null) {
securityRuleBuilder.setSecurityGroupId(toUuid(securityRule.getSecurityRuleGroupID()));
if (securityRule.getSecurityRuleProtocol() != null) {
ImmutableBiMap<String, Class<? extends ProtocolBase>> mapper =
PROTOCOL_MAP.inverse();
- securityRuleBuilder.setProtocol((Class<? extends ProtocolBase>) mapper.get(securityRule.getSecurityRuleProtocol()));
+ securityRuleBuilder.setProtocol(mapper.get(securityRule.getSecurityRuleProtocol()));
}
if (securityRule.getSecurityRuleEthertype() != null) {
ImmutableBiMap<String, Class<? extends EthertypeBase>> mapper =
ETHERTYPE_MAP.inverse();
- securityRuleBuilder.setEthertype((Class<? extends EthertypeBase>) mapper.get(securityRule.getSecurityRuleEthertype()));
+ securityRuleBuilder.setEthertype(mapper.get(securityRule.getSecurityRuleEthertype()));
}
if (securityRule.getSecurityRulePortMin() != null) {
securityRuleBuilder.setPortRangeMin(Integer.valueOf(securityRule.getSecurityRulePortMin()));
private static final ImmutableBiMap<Class<? extends IpVersionBase>,Integer> IPV_MAP
= new ImmutableBiMap.Builder<Class<? extends IpVersionBase>,Integer>()
- .put(IpVersionV4.class,Integer.valueOf(4))
- .put(IpVersionV6.class,Integer.valueOf(6))
+ .put(IpVersionV4.class, 4)
+ .put(IpVersionV6.class, 6)
.build();
private static final ImmutableBiMap<Class<? extends Dhcpv6Base>,String> DHCPV6_MAP
@Override
public List<NeutronSubnet> getAllSubnets() {
- Set<NeutronSubnet> allSubnets = new HashSet<NeutronSubnet>();
+ Set<NeutronSubnet> allSubnets = new HashSet<>();
Subnets subnets = readMd(createInstanceIdentifier());
if (subnets != null) {
for (Subnet subnet: subnets.getSubnet()) {
}
}
LOGGER.debug("Exiting getAllSubnets, Found {} OpenStackSubnets", allSubnets.size());
- List<NeutronSubnet> ans = new ArrayList<NeutronSubnet>();
+ List<NeutronSubnet> ans = new ArrayList<>();
ans.addAll(allSubnets);
return ans;
}
result.setIpV6AddressMode(DHCPV6_MAP.get(subnet.getIpv6AddressMode()));
result.setEnableDHCP(subnet.isEnableDhcp());
if (subnet.getAllocationPools() != null) {
- List<NeutronSubnetIPAllocationPool> allocationPools = new ArrayList<NeutronSubnetIPAllocationPool>();
+ List<NeutronSubnetIPAllocationPool> allocationPools = new ArrayList<>();
for (AllocationPools allocationPool : subnet.getAllocationPools()) {
NeutronSubnetIPAllocationPool pool = new NeutronSubnetIPAllocationPool();
pool.setPoolStart(allocationPool.getStart());
result.setAllocationPools(allocationPools);
}
if (subnet.getDnsNameservers() != null) {
- List<String> dnsNameServers = new ArrayList<String>();
+ List<String> dnsNameServers = new ArrayList<>();
for (IpAddress dnsNameServer : subnet.getDnsNameservers()) {
dnsNameServers.add(String.valueOf(dnsNameServer.getValue()));
}
// read through the ports and put the ones in this subnet into the internal
// myPorts object.
// @deprecated and will be removed in Boron
- Set<NeutronPort> allPorts = new HashSet<NeutronPort>();
+ Set<NeutronPort> allPorts = new HashSet<>();
NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
.fetchINeutronPortCRUD(this);
INeutronPortCRUD portIf = interfaces.getPortInterface();
}
}
}
- List<NeutronPort> ports = new ArrayList<NeutronPort>();
+ List<NeutronPort> ports = new ArrayList<>();
ports.addAll(allPorts);
result.setPorts(ports);
return result;
if (subnet.getIpVersion() != null) {
ImmutableBiMap<Integer, Class<? extends IpVersionBase>> mapper =
IPV_MAP.inverse();
- subnetBuilder.setIpVersion((Class<? extends IpVersionBase>) mapper.get(subnet
+ subnetBuilder.setIpVersion(mapper.get(subnet
.getIpVersion()));
}
if (subnet.getCidr() != null) {
if (subnet.getIpV6RaMode() != null) {
ImmutableBiMap<String, Class<? extends Dhcpv6Base>> mapper =
DHCPV6_MAP.inverse();
- subnetBuilder.setIpv6RaMode((Class<? extends Dhcpv6Base>) mapper.get(subnet.getIpV6RaMode()));
+ subnetBuilder.setIpv6RaMode(mapper.get(subnet.getIpV6RaMode()));
}
if (subnet.getIpV6AddressMode() != null) {
ImmutableBiMap<String, Class<? extends Dhcpv6Base>> mapper =
DHCPV6_MAP.inverse();
- subnetBuilder.setIpv6AddressMode((Class<? extends Dhcpv6Base>) mapper.get(subnet.getIpV6AddressMode()));
+ subnetBuilder.setIpv6AddressMode(mapper.get(subnet.getIpV6AddressMode()));
}
subnetBuilder.setEnableDhcp(subnet.getEnableDHCP());
if (subnet.getAllocationPools() != null) {
- List<AllocationPools> allocationPools = new ArrayList<AllocationPools>();
+ List<AllocationPools> allocationPools = new ArrayList<>();
for (NeutronSubnetIPAllocationPool allocationPool : subnet
.getAllocationPools()) {
AllocationPoolsBuilder builder = new AllocationPoolsBuilder();
subnetBuilder.setAllocationPools(allocationPools);
}
if (subnet.getDnsNameservers() != null) {
- List<IpAddress> dnsNameServers = new ArrayList<IpAddress>();
+ List<IpAddress> dnsNameServers = new ArrayList<>();
for (String dnsNameServer : subnet.getDnsNameservers()) {
IpAddress ipAddress = new IpAddress(dnsNameServer.toCharArray());
dnsNameServers.add(ipAddress);
package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter_Interface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
return instances;
}
+ public static List<Neutron_IPs> convertMDSalIpToNeutronIp(List<FixedIps> fixedIps) {
+ List<Neutron_IPs> ips = null;
+ if (fixedIps != null) {
+ ips = new ArrayList<Neutron_IPs>();
+ for (FixedIps mdIP : fixedIps) {
+ Neutron_IPs ip = new Neutron_IPs();
+ ip.setIpAddress(String.valueOf(mdIP.getIpAddress().getValue()));
+ ip.setSubnetUUID(mdIP.getSubnetId().getValue());
+ ips.add(ip);
+ }
+ }
+ return ips;
+ }
+
+ public static NeutronRouter_Interface convertMDSalInterfaceToNeutronRouterInterface(
+ Port routerInterface) {
+ NeutronRouter_Interface neutronInterface = new NeutronRouter_Interface();
+ String id = String.valueOf(routerInterface.getUuid().getValue());
+ neutronInterface.setID(id);
+ neutronInterface.setTenantID(routerInterface.getTenantId().getValue());
+ neutronInterface.setSubnetUUID(routerInterface.getFixedIps().get(0).getSubnetId().getValue());
+ neutronInterface.setPortUUID(routerInterface.getUuid().getValue());
+ return neutronInterface;
+ }
+
+
+
}
result.setShared(network.isShared());
result.setStatus(network.getStatus());
if (network.getSubnets() != null) {
- List<String> neutronSubnets = new ArrayList<String>();
+ List<String> neutronSubnets = new ArrayList<>();
for( Uuid subnet : network.getSubnets()) {
neutronSubnets.add(subnet.getValue());
}
result.setProviderPhysicalNetwork(providerExtension.getPhysicalNetwork());
result.setProviderSegmentationID(providerExtension.getSegmentationId());
result.setProviderNetworkType(NETWORK_MAP.get(providerExtension.getNetworkType()));
- List<NeutronNetwork_Segment> segments = new ArrayList<NeutronNetwork_Segment>();
+ List<NeutronNetwork_Segment> segments = new ArrayList<>();
if (providerExtension.getSegments() != null) {
for (Segments segment: providerExtension.getSegments()) {
NeutronNetwork_Segment neutronSegment = new NeutronNetwork_Segment();
NeutronPort result = new NeutronPort();
result.setAdminStateUp(port.isAdminStateUp());
if (port.getAllowedAddressPairs() != null) {
- List<NeutronPort_AllowedAddressPairs> pairs = new ArrayList<NeutronPort_AllowedAddressPairs>();
+ List<NeutronPort_AllowedAddressPairs> pairs = new ArrayList<>();
for (AllowedAddressPairs mdPair : port.getAllowedAddressPairs()) {
NeutronPort_AllowedAddressPairs pair = new NeutronPort_AllowedAddressPairs();
pair.setIpAddress(mdPair.getIpAddress());
result.setDeviceID(port.getDeviceId());
result.setDeviceOwner(port.getDeviceOwner());
if (port.getExtraDhcpOpts() != null) {
- List<NeutronPort_ExtraDHCPOption> options = new ArrayList<NeutronPort_ExtraDHCPOption>();
+ List<NeutronPort_ExtraDHCPOption> options = new ArrayList<>();
for (ExtraDhcpOpts opt : port.getExtraDhcpOpts()) {
NeutronPort_ExtraDHCPOption arg = new NeutronPort_ExtraDHCPOption();
arg.setName(opt.getOptName());
result.setExtraDHCPOptions(options);
}
if (port.getFixedIps() != null) {
- List<Neutron_IPs> ips = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> ips = new ArrayList<>();
for (FixedIps mdIP : port.getFixedIps()) {
Neutron_IPs ip = new Neutron_IPs();
ip.setIpAddress(String.valueOf(mdIP.getIpAddress().getValue()));
result.setName(port.getName());
result.setNetworkUUID(String.valueOf(port.getNetworkId().getValue()));
if (port.getSecurityGroups() != null) {
- Set<NeutronSecurityGroup> allGroups = new HashSet<NeutronSecurityGroup>();
+ Set<NeutronSecurityGroup> allGroups = new HashSet<>();
NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces().fetchINeutronSecurityGroupCRUD(this);
INeutronSecurityGroupCRUD sgIf = interfaces.getSecurityGroupInterface();
for (Uuid sgUuid : port.getSecurityGroups()) {
- allGroups.add(sgIf.getNeutronSecurityGroup(sgUuid.getValue()));
+ NeutronSecurityGroup secGroup = sgIf.getNeutronSecurityGroup(sgUuid.getValue());
+ if (secGroup != null) {
+ allGroups.add(sgIf.getNeutronSecurityGroup(sgUuid.getValue()));
+ }
}
- List<NeutronSecurityGroup> groups = new ArrayList<NeutronSecurityGroup>();
+ List<NeutronSecurityGroup> groups = new ArrayList<>();
groups.addAll(allGroups);
result.setSecurityGroups(groups);
}
PortBindingExtension binding = port.getAugmentation(PortBindingExtension.class);
result.setBindinghostID(binding.getHostId());
if (binding.getVifDetails() != null) {
- List<NeutronPort_VIFDetail> details = new ArrayList<NeutronPort_VIFDetail>();
+ List<NeutronPort_VIFDetail> details = new ArrayList<>();
for (VifDetails vifDetail : binding.getVifDetails()) {
NeutronPort_VIFDetail detail = new NeutronPort_VIFDetail();
detail.setPortFilter(vifDetail.isPortFilter());
private Map<String,NeutronPort> getChangedPorts(Map<InstanceIdentifier<?>, DataObject> changedData) {
LOG.trace("getChangedPorts:" + changedData);
- Map<String,NeutronPort> portMap = new HashMap<String,NeutronPort>();
+ Map<String,NeutronPort> portMap = new HashMap<>();
for (Map.Entry<InstanceIdentifier<?>, DataObject> changed : changedData.entrySet()) {
if (changed.getValue() instanceof Port) {
NeutronPort port = fromMd((Port)changed.getValue());
result.setGatewayPortId(String.valueOf(router.getGatewayPortId().getValue()));
}
if (router.getRoutes() != null) {
- List<String> routes = new ArrayList<String>();
+ List<String> routes = new ArrayList<>();
for (String route : router.getRoutes()) {
routes.add(route);
}
extGwInfo.setNetworkID(String.valueOf(router.getExternalGatewayInfo().getExternalNetworkId().getValue()));
extGwInfo.setEnableSNAT(router.getExternalGatewayInfo().isEnableSnat());
if (router.getExternalGatewayInfo().getExternalFixedIps() != null) {
- List<Neutron_IPs> fixedIPs = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> fixedIPs = new ArrayList<>();
for (ExternalFixedIps mdFixedIP : router.getExternalGatewayInfo().getExternalFixedIps()) {
Neutron_IPs fixedIP = new Neutron_IPs();
fixedIP.setSubnetUUID(String.valueOf(mdFixedIP.getSubnetId().getValue()));
}
if (router.getInterfaces() != null) {
- Map<String, NeutronRouter_Interface> interfaces = new HashMap<String, NeutronRouter_Interface>();
+ Map<String, NeutronRouter_Interface> interfaces = new HashMap<>();
for (Interfaces mdInterface : router.getInterfaces()) {
NeutronRouter_Interface pojoInterface = new NeutronRouter_Interface();
String id = String.valueOf(mdInterface.getUuid().getValue());
INeutronSecurityRuleCRUD srCrud = interfaces
.getSecurityRuleInterface();
- List<NeutronSecurityRule> rules = new ArrayList<NeutronSecurityRule>();
+ List<NeutronSecurityRule> rules = new ArrayList<>();
for (Uuid uuid : group.getSecurityRules()) {
rules.add(srCrud.getNeutronSecurityRule(uuid.getValue()));
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeV4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeV6;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolHttp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolHttps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolIcmp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolIcmpV6;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolTcp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolUdp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.SecurityRules;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
private static final Logger LOG = LoggerFactory.getLogger(NeutronSecurityRuleDataChangeListener.class);
private static final ImmutableBiMap<Class<? extends DirectionBase>, String> DIRECTION_MAP
- = new ImmutableBiMap.Builder<Class<? extends DirectionBase>, String>()
- .put(DirectionEgress.class, "egress")
- .put(DirectionIngress.class, "ingress").build();
- private static final ImmutableBiMap<Class<? extends ProtocolBase>, String> PROTOCOL_MAP
- = new ImmutableBiMap.Builder<Class<? extends ProtocolBase>, String>()
- .put(ProtocolHttp.class, "HTTP")
- .put(ProtocolHttps.class, "HTTPS")
- .put(ProtocolIcmp.class, "ICMP")
- .put(ProtocolTcp.class, "TCP")
+ = new ImmutableBiMap.Builder<Class<? extends DirectionBase>, String>()
+ .put(DirectionEgress.class, "egress")
+ .put(DirectionIngress.class, "ingress").build();
+ private static final ImmutableBiMap<Class<? extends ProtocolBase>,String> PROTOCOL_MAP
+ = new ImmutableBiMap.Builder<Class<? extends ProtocolBase>,String>()
+ .put(ProtocolIcmp.class,"icmp")
+ .put(ProtocolTcp.class,"tcp")
+ .put(ProtocolUdp.class,"udp")
+ .put(ProtocolIcmpV6.class,"icmpv6")
.build();
- private static final ImmutableBiMap<Class<? extends EthertypeBase>, String> ETHERTYPE_MAP
- = new ImmutableBiMap.Builder<Class<? extends EthertypeBase>, String>()
- .put(EthertypeV4.class, "v4")
- .put(EthertypeV6.class, "v6")
+ private static final ImmutableBiMap<Class<? extends EthertypeBase>,String> ETHERTYPE_MAP
+ = new ImmutableBiMap.Builder<Class<? extends EthertypeBase>,String>()
+ .put(EthertypeV4.class,"IPv4")
+ .put(EthertypeV6.class,"IPv6")
.build();
private ListenerRegistration<DataChangeListener> registration;
private static final ImmutableBiMap<Class<? extends IpVersionBase>,Integer> IPV_MAP
= new ImmutableBiMap.Builder<Class<? extends IpVersionBase>,Integer>()
- .put(IpVersionV4.class,Integer.valueOf(4))
- .put(IpVersionV6.class,Integer.valueOf(6))
+ .put(IpVersionV4.class, 4)
+ .put(IpVersionV6.class, 6)
.build();
private static final ImmutableBiMap<Class<? extends Dhcpv6Base>,String> DHCPV6_MAP
result.setIpV6AddressMode(DHCPV6_MAP.get(subnet.getIpv6AddressMode()));
result.setEnableDHCP(subnet.isEnableDhcp());
if (subnet.getAllocationPools() != null) {
- List<NeutronSubnetIPAllocationPool> allocationPools = new ArrayList<NeutronSubnetIPAllocationPool>();
+ List<NeutronSubnetIPAllocationPool> allocationPools = new ArrayList<>();
for (AllocationPools allocationPool : subnet.getAllocationPools()) {
NeutronSubnetIPAllocationPool pool = new NeutronSubnetIPAllocationPool();
pool.setPoolStart(allocationPool.getStart());
result.setAllocationPools(allocationPools);
}
if (subnet.getDnsNameservers() != null) {
- List<String> dnsNameServers = new ArrayList<String>();
+ List<String> dnsNameServers = new ArrayList<>();
for (IpAddress dnsNameServer : subnet.getDnsNameservers()) {
dnsNameServers.add(String.valueOf(dnsNameServer.getValue()));
}
// read through the ports and put the ones in this subnet into the internal
// myPorts object.
- Set<NeutronPort> allPorts = new HashSet<NeutronPort>();
+ Set<NeutronPort> allPorts = new HashSet<>();
NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
.fetchINeutronPortCRUD(this);
INeutronPortCRUD portIf = interfaces.getPortInterface();
}
}
}
- List<NeutronPort> ports = new ArrayList<NeutronPort>();
+ List<NeutronPort> ports = new ArrayList<>();
ports.addAll(allPorts);
result.setPorts(ports);
return result;
when(ev.getNeutronFloatingIP()).thenReturn(mock(NeutronFloatingIP.class));
when(ev.getAction()).thenReturn(Action.UPDATE);
- floatingHandler.processEvent((AbstractEvent) ev);
- verify(neutronL3Adapter, times(1)).handleNeutronFloatingIPEvent(ev.getNeutronFloatingIP(), ev.getAction());;
+ floatingHandler.processEvent(ev);
+ verify(neutronL3Adapter, times(1)).handleNeutronFloatingIPEvent(ev.getNeutronFloatingIP(), ev.getAction());
when(ev.getAction()).thenReturn(Action.ADD);
- floatingHandler.processEvent((AbstractEvent) ev);
- verify(neutronL3Adapter, times(1)).handleNeutronFloatingIPEvent(ev.getNeutronFloatingIP(), ev.getAction());;
+ floatingHandler.processEvent(ev);
+ verify(neutronL3Adapter, times(1)).handleNeutronFloatingIPEvent(ev.getNeutronFloatingIP(), ev.getAction());
when(ev.getAction()).thenReturn(Action.DELETE);
- floatingHandler.processEvent((AbstractEvent) ev);
- verify(neutronL3Adapter, times(1)).handleNeutronFloatingIPEvent(ev.getNeutronFloatingIP(), ev.getAction());;
+ floatingHandler.processEvent(ev);
+ verify(neutronL3Adapter, times(1)).handleNeutronFloatingIPEvent(ev.getNeutronFloatingIP(), ev.getAction());
}
@Test
public void setUp() {
when(neutronLBPool.getLoadBalancerPoolProtocol()).thenReturn(LoadBalancerConfiguration.PROTOCOL_HTTP);
- List<NeutronLoadBalancerPoolMember> members = new ArrayList<NeutronLoadBalancerPoolMember>();
+ List<NeutronLoadBalancerPoolMember> members = new ArrayList<>();
NeutronLoadBalancerPoolMember neutronLBPoolMember = mock(NeutronLoadBalancerPoolMember.class);
when(neutronLBPoolMember.getPoolMemberAdminStateIsUp()).thenReturn(true);
when(neutronLBPoolMember.getPoolMemberSubnetID()).thenReturn("subnetID");
members.add(neutronLBPoolMember);
when(neutronLBPool.getLoadBalancerPoolMembers()).thenReturn(members);
- List<NeutronLoadBalancer> list_neutronLB = new ArrayList<NeutronLoadBalancer>();
+ List<NeutronLoadBalancer> list_neutronLB = new ArrayList<>();
NeutronLoadBalancer neutronLB = mock(NeutronLoadBalancer.class);
when(neutronLB.getLoadBalancerName()).thenReturn("load_balancer_name");
when(neutronLB.getLoadBalancerVipAddress()).thenReturn("vip_address");
NorthboundEvent ev = mock(NorthboundEvent.class);
when(ev.getLoadBalancerPool()).thenReturn(neutronLBPool);
- List<Node> list_node = new ArrayList<Node>();
+ List<Node> list_node = new ArrayList<>();
list_node .add(mock(Node.class));
when(nodeCacheManager.getBridgeNodes()).thenReturn(list_node);
when(NeutronCacheUtils.getMacAddress(any(INeutronPortCRUD.class), anyString(), anyString())).thenReturn("mac_address");
when(NeutronCacheUtils.getProviderInformation(any(INeutronNetworkCRUD.class), any(INeutronSubnetCRUD.class), anyString())).thenReturn(providerInfo);
- List<NeutronLoadBalancerPoolMember> members = new ArrayList<NeutronLoadBalancerPoolMember>();
+ List<NeutronLoadBalancerPoolMember> members = new ArrayList<>();
NeutronLoadBalancerPoolMember neutronLBPoolMember = mock(NeutronLoadBalancerPoolMember.class);
when(neutronLBPoolMember.getPoolMemberAdminStateIsUp()).thenReturn(true);
when(neutronLBPoolMember.getPoolMemberSubnetID()).thenReturn("subnetID");
when(neutronLBPool.getLoadBalancerPoolMembers()).thenReturn(members);
when(neutronLBPoolCache.getNeutronLoadBalancerPool(anyString())).thenReturn(neutronLBPool);
- List<NeutronLoadBalancer> list_neutronLB = new ArrayList<NeutronLoadBalancer>();
+ List<NeutronLoadBalancer> list_neutronLB = new ArrayList<>();
NeutronLoadBalancer neutronLB = mock(NeutronLoadBalancer.class);
when(neutronLB.getLoadBalancerName()).thenReturn("load_balancer_name");
when(neutronLB.getLoadBalancerVipAddress()).thenReturn("vip_address");
NorthboundEvent ev = mock(NorthboundEvent.class);
when(ev.getLoadBalancerPoolMember()).thenReturn(neutronLBMember);
- List<Node> list_node = new ArrayList<Node>();
+ List<Node> list_node = new ArrayList<>();
list_node .add(mock(Node.class));
when(nodeCacheManager.getBridgeNodes()).thenReturn(list_node);
Neutron_IPs ip = mock(Neutron_IPs.class);
when(ip.getIpAddress()).thenReturn("ip_address");
when(ip.getSubnetUUID()).thenReturn("subnetUUID");
- List<Neutron_IPs> list_fixedIP = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> list_fixedIP = new ArrayList<>();
list_fixedIP.add(ip);
when(port.getFixedIPs()).thenReturn(list_fixedIP);
when(port.getMacAddress()).thenReturn("mac_address");
- List<NeutronPort> list_port = new ArrayList<NeutronPort>();
+ List<NeutronPort> list_port = new ArrayList<>();
list_port.add(port);
when(neutronPortsCache.getAllPorts()).thenReturn(list_port);
NeutronSubnet subnet = mock(NeutronSubnet.class);
when(subnet.getID()).thenReturn("subnetUUID");
when(subnet.getNetworkUUID()).thenReturn("networkUUID");
- List<NeutronSubnet> list_subnet = new ArrayList<NeutronSubnet>();
+ List<NeutronSubnet> list_subnet = new ArrayList<>();
list_subnet.add(subnet);
when(neutronSubnetCache.getAllSubnets()).thenReturn(list_subnet );
when(network.getID()).thenReturn("networkUUID");
when(network.getProviderNetworkType()).thenReturn("network_type_1");
when(network.getProviderSegmentationID()).thenReturn("network_segID");
- List<NeutronNetwork> list_network = new ArrayList<NeutronNetwork>();
+ List<NeutronNetwork> list_network = new ArrayList<>();
list_network.add(network);
when(neutronNetworkCache.getAllNetworks()).thenReturn(list_network);
- Map.Entry<String,String> entry = new AbstractMap.SimpleEntry<String, String>(
+ Map.Entry<String,String> entry = new AbstractMap.SimpleEntry<>(
network.getProviderNetworkType(), network.getProviderSegmentationID());
assertEquals("Error, getProviderInformation() did not return the correct values", entry, NeutronCacheUtils.getProviderInformation(neutronNetworkCache, neutronSubnetCache, "subnetUUID"));
portHandlerSpy.processEvent(ev);
verify(neutronL3Adapter, times(1)).handleNeutronPortEvent(neutronPort, Action.UPDATE);
- List<Node> nodes = new ArrayList<Node>();
+ List<Node> nodes = new ArrayList<>();
nodes.add(mock(Node.class));
when(nodeCacheManager.getNodes()).thenReturn(nodes);
- List<OvsdbTerminationPointAugmentation> ports = new ArrayList<OvsdbTerminationPointAugmentation>();
+ List<OvsdbTerminationPointAugmentation> ports = new ArrayList<>();
OvsdbTerminationPointAugmentation port = mock(OvsdbTerminationPointAugmentation.class);
ports.add(port);
when(southbound.getTerminationPointsOfBridge(any(Node.class))).thenReturn(ports);
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
+import org.mockito.Mock;
import org.mockito.Mockito;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
@InjectMocks private PortSecurityHandler portSecurityHandler;
private PortSecurityHandler posrtSecurityHandlerSpy;
+ @Mock EventDispatcher eventDispatcher;
@Before
public void setUp() {
assertEquals("Error, did not return the correct HTTP flag", HttpURLConnection.HTTP_CREATED, portSecurityHandler.canCreateNeutronSecurityRule(mock(NeutronSecurityRule.class)));
posrtSecurityHandlerSpy.neutronSecurityRuleCreated(any(NeutronSecurityRule.class));
- verify(posrtSecurityHandlerSpy, times(1)).canCreateNeutronSecurityRule(any(NeutronSecurityRule.class));
+ verify(posrtSecurityHandlerSpy, times(1)).enqueueEvent(any(AbstractEvent.class));
}
@Test
assertEquals("Error, did not return the correct HTTP flag", HttpURLConnection.HTTP_OK, portSecurityHandler.canDeleteNeutronSecurityRule(mock(NeutronSecurityRule.class)));
posrtSecurityHandlerSpy.neutronSecurityRuleDeleted(any(NeutronSecurityRule.class));
- verify(posrtSecurityHandlerSpy, times(1)).canDeleteNeutronSecurityRule(any(NeutronSecurityRule.class));
+ verify(posrtSecurityHandlerSpy, times(1)).enqueueEvent(any(AbstractEvent.class));
}
@Test
Node node = mock(Node.class);
when(node.getAugmentation(OvsdbNodeAugmentation.class)).thenReturn(mock(OvsdbNodeAugmentation.class));
- List<Node> nodes = new ArrayList<Node>();
+ List<Node> nodes = new ArrayList<>();
nodes.add(mock(Node.class));
when(southbound.readOvsdbTopologyNodes()).thenReturn(nodes);
southboundHandlerSpy.triggerUpdates();
- verify(southboundHandlerSpy, times(1)).ovsdbUpdate(any(Node.class), any(DataObject.class), any(OvsdbType.class), any(Action.class));;
+ verify(southboundHandlerSpy, times(1)).ovsdbUpdate(any(Node.class), any(DataObject.class), any(OvsdbType.class), any(Action.class));
+
}
@Test
when(ev.getType()).thenReturn(Type.OPENVSWITCH);
when(ovsdbTerminationPointAugmentation.getName()).thenReturn("network");
- List<TerminationPoint> terminationPoints = new ArrayList<TerminationPoint>();
+ List<TerminationPoint> terminationPoints = new ArrayList<>();
terminationPoints.add(mock(TerminationPoint.class));
when(southbound.extractTerminationPoints(any(Node.class))).thenReturn(terminationPoints);
when(ev.getAction()).thenReturn(Action.ADD);
subnetHandler.processEvent(ev);
- verify(neutronl3Adapter, times(1)).handleNeutronSubnetEvent(ev.getSubnet(), ev.getAction());;
+ verify(neutronl3Adapter, times(1)).handleNeutronSubnetEvent(ev.getSubnet(), ev.getAction());
when(ev.getAction()).thenReturn(Action.DELETE);
subnetHandler.processEvent(ev);
- verify(neutronl3Adapter, times(1)).handleNeutronSubnetEvent(ev.getSubnet(), ev.getAction());;
+ verify(neutronl3Adapter, times(1)).handleNeutronSubnetEvent(ev.getSubnet(), ev.getAction());
when(ev.getAction()).thenReturn(Action.UPDATE);
subnetHandler.processEvent(ev);
- verify(neutronl3Adapter, times(1)).handleNeutronSubnetEvent(ev.getSubnet(), ev.getAction());;
+ verify(neutronl3Adapter, times(1)).handleNeutronSubnetEvent(ev.getSubnet(), ev.getAction());
}
@Test
{"10.10.1.343", "10.10.1.391", "10.10.1.31"},
{"D5:6B:59:E8:F4:84", "D5:4B:60:E8:F5:84", "D5:4B:60:E8:F6:84"},
{"tcp", "tcp", "http"},
- {Integer.valueOf(125304), Integer.valueOf(125304), Integer.valueOf(1204)}};
+ {125304, 125304, 1204}};
@Before
public void setUp() throws Exception {
assertTrue("Error, isCreated is not true for " + networkType,
bridgeConfigurationManagerImplSpy.createLocalNetwork(node, neutronNetworkMock));
- if (networkType.equals("vlan")) {
- verify(neutronNetworkMock, times(1)).getProviderNetworkType();
- } else if (networkType.equals("vxlan")) {
- verify(neutronNetworkMock, times(2)).getProviderNetworkType();
- } else if (networkType.equals("gre")) {
- verify(neutronNetworkMock, times(3)).getProviderNetworkType();
+ switch (networkType) {
+ case "vlan":
+ verify(neutronNetworkMock, times(1)).getProviderNetworkType();
+ break;
+ case "vxlan":
+ verify(neutronNetworkMock, times(2)).getProviderNetworkType();
+ break;
+ case "gre":
+ verify(neutronNetworkMock, times(3)).getProviderNetworkType();
+ break;
}
reset(neutronNetworkMock);
reset(node);
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.stubbing.OngoingStubbing;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
+import org.powermock.api.mockito.PowerMockito;
+
/**
* Unit test for class {@link MdsalUtils}
*
@Mock private DataBroker databroker;
@Test
- public void testDelete() {
+ public void testDelete() throws ReadFailedException{
WriteTransaction writeTransaction = mock(WriteTransaction.class);
when(databroker.newWriteOnlyTransaction()).thenReturn(writeTransaction);
CheckedFuture<Void, TransactionCommitFailedException> future = mock(CheckedFuture.class);
when(writeTransaction.submit()).thenReturn(future );
+ InstanceIdentifier<?> iid = mock(InstanceIdentifier.class);
+
+ ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class);
+ when(databroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction);
+ CheckedFuture<Optional, ReadFailedException> futureRead = mock(CheckedFuture.class);
+ Optional opt = mock(Optional.class);
+ when(opt.isPresent()).thenReturn(true);
+ DataObject obj = mock(DataObject.class);
+ when(opt.get()).thenReturn(obj );
+ when(futureRead.checkedGet()).thenReturn(opt);
+ when(readOnlyTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))).thenReturn(futureRead);
- boolean result = mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, mock(InstanceIdentifier.class));
+ boolean result = mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, iid);
verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
verify(writeTransaction, times(1)).submit();
@Test
public void testHandleNeutronPortEvent() throws Exception {
- Map<String, NeutronRouter_Interface> subnetIdToRouterInterfaceCache = new HashMap<String, NeutronRouter_Interface>();
+ Map<String, NeutronRouter_Interface> subnetIdToRouterInterfaceCache = new HashMap<>();
// Mock variables
Neutron_IPs neutronIP = mock(Neutron_IPs.class);
when(neutronIP.getSubnetUUID()).thenReturn(UUID);
- List<Neutron_IPs> list_neutronIP = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> list_neutronIP = new ArrayList<>();
list_neutronIP.add(neutronIP);
NeutronPort neutronPort = mock(NeutronPort.class);
when(neutronPort.getDeviceOwner()).thenReturn(OWNER_ROUTER_INTERFACE);
Neutron_IPs neutronIP = mock(Neutron_IPs.class);
when(neutronIP.getSubnetUUID()).thenReturn(UUID);
NeutronPort neutronPort = mock(NeutronPort.class);
- List<Neutron_IPs> list_neutronIP = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> list_neutronIP = new ArrayList<>();
list_neutronIP.add(neutronIP);
when(neutronPort.getFixedIPs()).thenReturn(list_neutronIP);
List<NeutronPort> list_neutronPort = new ArrayList<>();
// Suppress the called to these functions
MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programOutboundIpRewriteStage1", floatingIpClass, Action.class));
-
+ PowerMockito.doReturn(floatIpDataMapCache.values()).when(neutronL3Adapter, "getAllFloatingIPsWithMetadata");
Whitebox.invokeMethod(neutronL3Adapter, "flushExistingIpRewrite");
PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programOutboundIpRewriteStage1", any(floatingIpClass), eq(Action.DELETE));
}
// Suppress the called to these functions
MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programOutboundIpRewriteStage1", floatingIpClass, Action.class));
+ PowerMockito.doReturn(floatIpDataMapCache.values()).when(neutronL3Adapter, "getAllFloatingIPsWithMetadata");
Whitebox.invokeMethod(neutronL3Adapter, "rebuildExistingIpRewrite");
PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programOutboundIpRewriteStage1", any(floatingIpClass), eq(Action.ADD));
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testProgramFlowsForFloatingIPArpAdd() throws Exception {
- Map<String, Pair> neutronPortToDpIdCache = new HashMap<String, Pair>();
- Map<String, String> networkIdToRouterMacCache = new HashMap<String, String>();
+ Map<String, Pair> neutronPortToDpIdCache = new HashMap<>();
+ Map<String, String> networkIdToRouterMacCache = new HashMap<>();
Map floatIpDataMapCache = new HashMap();
NeutronFloatingIP neutronFloatingIP = mock(NeutronFloatingIP.class);
INeutronPortCRUD neutronPortCache = mock(INeutronPortCRUD.class);
when(neutronPortCache.getPort(anyString())).thenReturn(neutronPort);
PowerMockito.doReturn(neutronPort).when(neutronL3Adapter, "findNeutronPortForFloatingIp", anyString());
- PowerMockito.doReturn(Long.valueOf(15)).when(neutronL3Adapter, "findOFPortForExtPatch", anyLong());
+ PowerMockito.doReturn(15L).when(neutronL3Adapter, "findOFPortForExtPatch", anyLong());
MemberModifier.field(NeutronL3Adapter.class, "floatIpDataMapCache").set(neutronL3Adapter , floatIpDataMapCache);
MemberModifier.field(NeutronL3Adapter.class, "neutronPortToDpIdCache").set(neutronL3Adapter , neutronPortToDpIdCache);
MemberModifier.field(NeutronL3Adapter.class, "neutronPortCache").set(neutronL3Adapter , neutronPortCache);
ConfigurationService configurationService = mock(ConfigurationService.class);
when(configurationService.getPatchPortName(any(Pair.class))).thenReturn(PORT_INT);
MemberModifier.field(NeutronL3Adapter.class, "configurationService").set(neutronL3Adapter , configurationService);
- List<Node> nodes = new ArrayList<Node>();
+ List<Node> nodes = new ArrayList<>();
nodes.add(mock(Node.class));
NodeCacheManager nodeCacheManager = mock(NodeCacheManager.class);
when(nodeCacheManager.getBridgeNodes()).thenReturn(nodes);
@Test
public void testHandleInterfaceEvent() throws Exception {
- Map<String, Pair<Long, Uuid>> neutronPortToDpIdCache = new HashMap<String, Pair<Long,Uuid>>();
+ Map<String, Pair<Long, Uuid>> neutronPortToDpIdCache = new HashMap<>();
// init instance variables
TenantNetworkManager tenantNetworkManager = mock(TenantNetworkManager.class);
MemberModifier.field(NeutronL3Adapter.class, "tenantNetworkManager").set(neutronL3Adapter , tenantNetworkManager);
MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "handleInterfaceEventAdd", String.class, Long.class, Uuid.class));
MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "handleInterfaceEventDelete", OvsdbTerminationPointAugmentation.class, Long.class));
- PowerMockito.when(neutronL3Adapter, "getDpidForIntegrationBridge", any(Node.class)).thenReturn(Long.valueOf(45));
+ PowerMockito.when(neutronL3Adapter, "getDpidForIntegrationBridge", any(Node.class)).thenReturn(45L);
Mockito.doNothing().when(neutronL3Adapter).handleNeutronPortEvent(any(NeutronPort.class), any(Action.class));
neutronL3Adapter.handleInterfaceEvent(node, intf, mock(NeutronNetwork.class), Action.ADD);
@Test
public void testHandleInterfaceEventAdd() throws Exception {
- Map<String, Pair<Long, Uuid>> neutronPortToDpIdCache = new HashMap<String, Pair<Long,Uuid>>();
+ Map<String, Pair<Long, Uuid>> neutronPortToDpIdCache = new HashMap<>();
// init instance variables
MemberModifier.field(NeutronL3Adapter.class, "neutronPortToDpIdCache").set(neutronL3Adapter , neutronPortToDpIdCache);
int temp = neutronPortToDpIdCache.size();
@SuppressWarnings("unchecked")
@Test
public void testHandleInterfaceEventDelete() throws Exception {
- Map<String, Pair<Long, Uuid>> neutronPortToDpIdCache = new HashMap<String, Pair<Long,Uuid>>();
+ Map<String, Pair<Long, Uuid>> neutronPortToDpIdCache = new HashMap<>();
OvsdbTerminationPointAugmentation intf = mock(OvsdbTerminationPointAugmentation.class);
Uuid uuid = mock(Uuid.class);
when(intf.getInterfaceUuid()).thenReturn(uuid );
@Test
public void testUpdateL3ForNeutronPort() throws Exception {
- Map<String, String> networkIdToRouterMacCache = new HashMap<String, String>();
+ Map<String, String> networkIdToRouterMacCache = new HashMap<>();
Neutron_IPs neutronIp = mock(Neutron_IPs.class);
when(neutronIp.getIpAddress()).thenReturn(FIXED_IP_ADDRESS);
- List<Neutron_IPs> neutronIps = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> neutronIps = new ArrayList<>();
neutronIps.add(neutronIp);
NeutronPort neutronPort = mock(NeutronPort.class);
when(neutronPort.getNetworkUUID()).thenReturn(UUID);
when(neutronPort.getFixedIPs()).thenReturn(neutronIps);
NeutronNetwork neutronNetwork = mock(NeutronNetwork.class);
when(neutronNetwork.getProviderSegmentationID()).thenReturn(ID);
- List<Node> nodes = new ArrayList<Node>();
+ List<Node> nodes = new ArrayList<>();
nodes.add(mock(Node.class));
- PowerMockito.doReturn(Long.valueOf(15)).when(neutronL3Adapter, "getDpidForIntegrationBridge", any(Node.class));
+ PowerMockito.doReturn(15L).when(neutronL3Adapter, "getDpidForIntegrationBridge", any(Node.class));
// init instance variables
networkIdToRouterMacCache .put(UUID, MAC_ADDRESS);
PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programStaticArpStage1", anyLong(), anyString(), anyString(), anyString(), eq(Action.DELETE));
}
- // either add or remove item in l3ForwardingCache
@Test
public void testProgramL3ForwardingStage1() throws Exception {
- Set<String> l3ForwardingCache = new HashSet<String>();
NodeId nodeId = mock(NodeId.class);
when(nodeId.getValue()).thenReturn(ID);
MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programL3ForwardingStage2", Node.class, Long.class, String.class, String.class, String.class, Action.class));
// init instance variables
- MemberModifier.field(NeutronL3Adapter.class, "l3ForwardingCache").set(neutronL3Adapter , l3ForwardingCache );
PowerMockito.when(neutronL3Adapter, "programL3ForwardingStage2", any(Node.class), anyLong(), anyString(), anyString(), anyString(), eq(Action.ADD)).thenReturn(new Status(StatusCode.SUCCESS));
PowerMockito.when(neutronL3Adapter, "programL3ForwardingStage2", any(Node.class), anyLong(), anyString(), anyString(), anyString(), eq(Action.DELETE)).thenReturn(new Status(StatusCode.SUCCESS));
- int temp = l3ForwardingCache.size();
Whitebox.invokeMethod(neutronL3Adapter, "programL3ForwardingStage1", node, Long.valueOf(45), SEG_ID, MAC_ADDRESS, IP, Action.ADD);
PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programL3ForwardingStage2", any(Node.class), anyLong(), anyString(), anyString(), anyString(), eq(Action.ADD));
- assertEquals("Error, did not add the value", temp, l3ForwardingCache.size()-1);
- l3ForwardingCache.add(node.getNodeId().getValue() + ":" + SEG_ID + ":" + IP);
- temp = l3ForwardingCache.size();
Whitebox.invokeMethod(neutronL3Adapter, "programL3ForwardingStage1", node, Long.valueOf(45), SEG_ID, MAC_ADDRESS, IP, Action.DELETE);
PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programL3ForwardingStage2", any(Node.class), anyLong(), anyString(), anyString(), anyString(), eq(Action.DELETE));
- assertEquals("Error, did not delete the value", temp, l3ForwardingCache.size()+1);
}
@Test
@Test
public void testProgramFlowsForNeutronRouterInterface() throws Exception {
- Map<String, String> networkIdToRouterMacCache = new HashMap<String, String>();
- Map<String, List<Neutron_IPs>> networkIdToRouterIpListCache = new HashMap<String, List<Neutron_IPs>>();
- Map<String, NeutronRouter_Interface> subnetIdToRouterInterfaceCache = new HashMap<String, NeutronRouter_Interface>();
+ Map<String, String> networkIdToRouterMacCache = new HashMap<>();
+ Map<String, List<Neutron_IPs>> networkIdToRouterIpListCache = new HashMap<>();
+ Map<String, NeutronRouter_Interface> subnetIdToRouterInterfaceCache = new HashMap<>();
NeutronRouter_Interface intf = mock(NeutronRouter_Interface.class);
when(intf.getPortUUID()).thenReturn(UUID);
when(intf.getSubnetUUID()).thenReturn(UUID);
Neutron_IPs neutronIp = mock(Neutron_IPs.class);
when(neutronIp.getIpAddress()).thenReturn(FIXED_IP_ADDRESS);
- List<Neutron_IPs> ips = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> ips = new ArrayList<>();
ips.add(neutronIp);
NeutronPort neutronPort = mock(NeutronPort.class);
when(neutronPort.getMacAddress()).thenReturn(MAC_ADDRESS);
NeutronRouter neutronRouter = mock(NeutronRouter.class);
Node node = mock(Node.class);
- List<Node> nodes = new ArrayList<Node>();
+ List<Node> nodes = new ArrayList<>();
nodes.add(node);
MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "getDpidForIntegrationBridge", Node.class));
MemberModifier.field(NeutronL3Adapter.class, "neutronSubnetCache").set(neutronL3Adapter , neutronSubnetCache);
MemberModifier.field(NeutronL3Adapter.class, "neutronNetworkCache").set(neutronL3Adapter , neutronNetworkCache);
MemberModifier.field(NeutronL3Adapter.class, "nodeCacheManager").set(neutronL3Adapter , nodeCacheManager);
- PowerMockito.when(neutronL3Adapter, "getDpidForIntegrationBridge", any(Node.class)).thenReturn(Long.valueOf(45));
+ PowerMockito.when(neutronL3Adapter, "getDpidForIntegrationBridge", any(Node.class)).thenReturn(45L);
int networkIdToRouterMacCacheSize, networkIdToRouterIpListCacheSize, subnetIdToRouterInterfaceCacheSize;
networkIdToRouterMacCacheSize = networkIdToRouterMacCache.size();
when(neutronNetwork.getProviderSegmentationID()).thenReturn(ID);
Neutron_IPs ip = mock(Neutron_IPs.class);
when(ip.getIpAddress()).thenReturn(IP);
- List<Neutron_IPs> ips = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> ips = new ArrayList<>();
ips.add(ip);
ips.add(ip);
ips.add(ip);
@Test
public void testProgramRouterInterfaceStage1() throws Exception {
- Set<String> routerInterfacesCache = new HashSet<String>();
NodeId nodeId = mock(NodeId.class);
when(nodeId.getValue()).thenReturn(ID);
MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programRouterInterfaceStage2", Node.class, Long.class, String.class, String.class, String.class, String.class, int.class, Action.class));
- MemberModifier.field(NeutronL3Adapter.class, "routerInterfacesCache").set(neutronL3Adapter , routerInterfacesCache);
PowerMockito.when(neutronL3Adapter, "programRouterInterfaceStage2", any(Node.class), anyLong(), anyString(), anyString(), anyString(), anyString(), anyInt(), any(Action.class)).thenReturn(new Status(StatusCode.SUCCESS));
- int t = routerInterfacesCache.size();
Whitebox.invokeMethod(neutronL3Adapter, "programRouterInterfaceStage1", node, Long.valueOf(12), SEG_ID, SEG_ID, MAC_ADDRESS, IP, 4, Action.ADD);
PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programRouterInterfaceStage1", any(Node.class), anyLong(), anyString(), anyString(), anyString(), anyString(), anyInt(), eq(Action.ADD));
- assertEquals("Error, did not add the interface", t, routerInterfacesCache.size() - 1);
- t = routerInterfacesCache.size();
Whitebox.invokeMethod(neutronL3Adapter, "programRouterInterfaceStage1", node, Long.valueOf(12), SEG_ID, SEG_ID, MAC_ADDRESS, IP, 4, Action.DELETE);
PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programRouterInterfaceStage1", any(Node.class), anyLong(), anyString(), anyString(), anyString(), anyString(), anyInt(), eq(Action.DELETE));
- assertEquals("Error, did not delete the interface", t, routerInterfacesCache.size() + 1);
}
- // either add or remove routerInterfacesCache
@Test
public void testProgramRouterInterfaceStage2() throws Exception {
NodeId nodeId = mock(NodeId.class);
}
- //either add or remove staticArpEntryCache
@Test
public void testProgramStaticArpStage1() throws Exception {
- Set<String> staticArpEntryCache = new HashSet<String>();
MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programStaticArpStage2", Long.class, String.class, String.class, String.class, Action.class));
- MemberModifier.field(NeutronL3Adapter.class, "staticArpEntryCache").set(neutronL3Adapter , staticArpEntryCache);
PowerMockito.when(neutronL3Adapter, "programStaticArpStage2", anyLong(), anyString(), anyString(), anyString(), any(Action.class)).thenReturn(new Status(StatusCode.SUCCESS));
- int t = staticArpEntryCache.size();
Whitebox.invokeMethod(neutronL3Adapter, "programStaticArpStage1", Long.valueOf(12), PORT_INT, MAC_ADDRESS, IP, Action.ADD);
PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programStaticArpStage2", anyLong(), anyString(), anyString(), anyString(), eq(Action.ADD));
- assertEquals("Error, did not add the static arp", t, staticArpEntryCache.size() - 1);
- t = staticArpEntryCache.size();
Whitebox.invokeMethod(neutronL3Adapter, "programStaticArpStage1", Long.valueOf(12), PORT_INT, MAC_ADDRESS, IP, Action.DELETE);
PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programStaticArpStage2", anyLong(), anyString(), anyString(), anyString(), eq(Action.DELETE));
- assertEquals("Error, did not delete the static arp", t, staticArpEntryCache.size() + 1);
}
@Test
assertEquals("Error, this not return the correct status code", new Status(StatusCode.SUCCESS), Whitebox.invokeMethod(neutronL3Adapter, "programStaticArpStage2", Long.valueOf(45), PORT_INT, MAC_ADDRESS, IP, Action.ADD));
}
- // either add or remove inboundIpRewriteCache
@Test
public void testProgramInboundIpRewriteStage1() throws Exception {
- Set<String> inboundIpRewriteCache = new HashSet<String>();
MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programInboundIpRewriteStage2", Long.class, Long.class, String.class, String.class, String.class, Action.class));
- MemberModifier.field(NeutronL3Adapter.class, "inboundIpRewriteCache").set(neutronL3Adapter , inboundIpRewriteCache);
PowerMockito.when(neutronL3Adapter, "programInboundIpRewriteStage2", anyLong(), anyLong(), anyString(), anyString(), anyString(), any(Action.class)).thenReturn(new Status(StatusCode.SUCCESS));
- int t = inboundIpRewriteCache.size();
Whitebox.invokeMethod(neutronL3Adapter, "programInboundIpRewriteStage1", Long.valueOf(12), Long.valueOf(12), PORT_INT, MAC_ADDRESS, IP, Action.ADD);
PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programInboundIpRewriteStage2", anyLong(), anyLong(), anyString(), anyString(), anyString(), eq(Action.ADD));
- assertEquals("Error, did not add the inboundIpRewrite", t, inboundIpRewriteCache.size() - 1);
- t = inboundIpRewriteCache.size();
Whitebox.invokeMethod(neutronL3Adapter, "programInboundIpRewriteStage1", Long.valueOf(12), Long.valueOf(12),PORT_INT, MAC_ADDRESS, IP, Action.DELETE);
PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programInboundIpRewriteStage2", anyLong(), anyLong(), anyString(), anyString(), anyString(), eq(Action.DELETE));
- assertEquals("Error, did not delete the inboundIpRewrite", t, inboundIpRewriteCache.size() + 1);
}
@Test
assertEquals("Error, this not return the correct status code", new Status(StatusCode.SUCCESS), Whitebox.invokeMethod(neutronL3Adapter, "programInboundIpRewriteStage2", Long.valueOf(45), Long.valueOf(45), SEG_ID, MAC_ADDRESS, IP, Action.ADD));
}
- // either add or remove outboundIpRewriteExclusionCache
@Test
public void testProgramIpRewriteExclusionStage1() throws Exception {
- Set<String> outboundIpRewriteExclusionCache = new HashSet<String>();
NodeId nodeId = mock(NodeId.class);
when(nodeId.getValue()).thenReturn(ID);
MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programIpRewriteExclusionStage2", Node.class, Long.class, String.class, String.class, Action.class));
- MemberModifier.field(NeutronL3Adapter.class, "outboundIpRewriteExclusionCache").set(neutronL3Adapter , outboundIpRewriteExclusionCache);
PowerMockito.when(neutronL3Adapter, "programIpRewriteExclusionStage2", any(Node.class), anyLong(), anyString(), anyString(), any(Action.class)).thenReturn(new Status(StatusCode.SUCCESS));
- int t = outboundIpRewriteExclusionCache.size();
Whitebox.invokeMethod(neutronL3Adapter, "programIpRewriteExclusionStage1", node, Long.valueOf(12), SEG_ID, CIDR, Action.ADD);
PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programIpRewriteExclusionStage2", any(Node.class), anyLong(), anyString(), anyString(), eq(Action.ADD));
- assertEquals("Error, did not add the outboundIpRewriteExclusion", t, outboundIpRewriteExclusionCache.size() - 1);
- t = outboundIpRewriteExclusionCache.size();
Whitebox.invokeMethod(neutronL3Adapter, "programIpRewriteExclusionStage1", node, Long.valueOf(12), SEG_ID, CIDR, Action.DELETE);
PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programIpRewriteExclusionStage2", any(Node.class), anyLong(), anyString(), anyString(), eq(Action.DELETE));
- assertEquals("Error, did not delete the outboundIpRewriteExclusion", t, outboundIpRewriteExclusionCache.size() + 1);
}
@Test
assertEquals("Error, this not return the correct status code", new Status(StatusCode.SUCCESS), Whitebox.invokeMethod(neutronL3Adapter, "programIpRewriteExclusionStage2", node, Long.valueOf(45), SEG_ID, CIDR, Action.ADD));
}
- // either add or remove outboundIpRewriteCache
@SuppressWarnings("unchecked")
@Test
public void testProgramOutboundIpRewriteStage1() throws Exception{
- Set<String> outboundIpRewriteCache = new HashSet<String>();
MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programOutboundIpRewriteStage2", floatingIpClass, Action.class));
- MemberModifier.field(NeutronL3Adapter.class, "outboundIpRewriteCache").set(neutronL3Adapter , outboundIpRewriteCache);
PowerMockito.when(neutronL3Adapter, "programOutboundIpRewriteStage2", any(floatingIpClass), any(Action.class)).thenReturn(new Status(StatusCode.SUCCESS));
- int t = outboundIpRewriteCache.size();
Whitebox.invokeMethod(neutronL3Adapter, "programOutboundIpRewriteStage1", floatingIpObject, Action.ADD);
PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programOutboundIpRewriteStage2", any(floatingIpClass), eq(Action.ADD));
- assertEquals("Error, did not add the outbound ip", t, outboundIpRewriteCache.size() - 1);
- t = outboundIpRewriteCache.size();
Whitebox.invokeMethod(neutronL3Adapter, "programOutboundIpRewriteStage1", floatingIpObject, Action.DELETE);
PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programOutboundIpRewriteStage2", any(floatingIpClass), eq(Action.DELETE));
- assertEquals("Error, did not delete the outbound ip", t, outboundIpRewriteCache.size() + 1);
}
/*@Test
PowerMockito.when(southbound.getBridge(any(Node.class), anyString())).thenReturn(mock(OvsdbBridgeAugmentation.class));
PowerMockito.when(configurationService.getIntegrationBridgeName()).thenReturn("");
- PowerMockito.when(southbound.getDataPathId(any(Node.class))).thenReturn(Long.valueOf(45));
+ PowerMockito.when(southbound.getDataPathId(any(Node.class))).thenReturn(45L);
- assertEquals("Error, did not return the correct Dpid", Long.valueOf(45), Whitebox.invokeMethod(neutronL3Adapter, "getDpidForIntegrationBridge", mock(Node.class)));
+ assertEquals("Error, did not return the correct Dpid", 45L, Whitebox.invokeMethod(neutronL3Adapter, "getDpidForIntegrationBridge", mock(Node.class)));
}
@Test
public void testencodeExcplicitOFPort() throws Exception {
- assertEquals("Error, did not correctly encode the port", OFPort, NeutronL3Adapter.encodeExcplicitOFPort(Long.valueOf(45)));
+ assertEquals("Error, did not correctly encode the port", OFPort, NeutronL3Adapter.encodeExcplicitOFPort(45L));
}
@Test
@Test
public void testSetDependenciesObject() throws Exception{
+ MemberModifier.field(NeutronL3Adapter.class, "enabled").set(neutronL3Adapter , false);
+
INeutronNetworkCRUD iNeutronNetworkCRUD = mock(INeutronNetworkCRUD.class);
neutronL3Adapter.setDependencies(iNeutronNetworkCRUD);
assertEquals("Error, did not return the correct object", getField("neutronNetworkCache"), iNeutronNetworkCRUD);
L3ForwardingProvider l3ForwardingProvider = mock(L3ForwardingProvider.class);
neutronL3Adapter.setDependencies(l3ForwardingProvider);
assertEquals("Error, did not return the correct object", getField("l3ForwardingProvider"), l3ForwardingProvider);
+
+ MemberModifier.field(NeutronL3Adapter.class, "enabled").set(neutronL3Adapter , true);
}
private Object getField(String fieldName) throws Exception {
Class clazz = Whitebox.getInnerClassType(NeutronL3Adapter.class, "FloatIpData");
Constructor [] constructors = clazz.getConstructors();
Constructor c = constructors[0];
- return c.newInstance(new NeutronL3Adapter(), Long.valueOf(415), Long.valueOf(415), "a", "b", "c", "d", "e");
+ return c.newInstance(neutronL3Adapter, 415L, 415L, "a", "b", "c", "d", "e");
}
}
@Test
public void testCacheListenerAddedAndRemoved() {
ServiceReference ref = mock(ServiceReference.class);
- when(ref.getProperty(org.osgi.framework.Constants.SERVICE_ID)).thenReturn(Long.valueOf(1));
+ when(ref.getProperty(org.osgi.framework.Constants.SERVICE_ID)).thenReturn(1L);
// add
nodeCacheManagerImpl.cacheListenerAdded(ref, mock(NodeCacheListener.class));
Map<?, ?> map = (HashMap<?, ?>) getField("providers");
ServiceReference<?> ref = mock(ServiceReference.class);
- when(ref.getProperty(org.osgi.framework.Constants.SERVICE_ID)).thenReturn(Long.valueOf(1));
+ when(ref.getProperty(org.osgi.framework.Constants.SERVICE_ID)).thenReturn(1L);
providerNetworkManagerImpl.providerAdded(ref, mock(NetworkingProvider.class));
public void setUp(){
NeutronPort neutronPort = mock(NeutronPort.class);
- List<NeutronSecurityGroup> securityGroups = new ArrayList<NeutronSecurityGroup>();
+ List<NeutronSecurityGroup> securityGroups = new ArrayList<>();
securityGroups.add(neutronSecurityGroup);
when(neutronPort.getSecurityGroups()).thenReturn(securityGroups);
NeutronNetwork neutronNetwork = mock(NeutronNetwork.class);
when(neutronNetwork.getProviderSegmentationID()).thenReturn(SEG_ID);
when(neutronNetwork.getNetworkUUID()).thenReturn(NETWORK_ID);
- List<NeutronNetwork> listNeutronNetwork = new ArrayList<NeutronNetwork>();
+ List<NeutronNetwork> listNeutronNetwork = new ArrayList<>();
listNeutronNetwork.add(neutronNetwork);
when(neutronNetworkCache.getAllNetworks()).thenReturn(listNeutronNetwork);
when(neutronPort.getNetworkUUID()).thenReturn(NETWORK_ID);
when(neutronPortCache.getPort(anyString())).thenReturn(neutronPort);
- List<OvsdbTerminationPointAugmentation> ports = new ArrayList<OvsdbTerminationPointAugmentation>();
+ List<OvsdbTerminationPointAugmentation> ports = new ArrayList<>();
ports.add(mock(OvsdbTerminationPointAugmentation.class));
when(southbound.getTerminationPointsOfBridge(any(Node.class))).thenReturn(ports);
@Test
public void testGetNetworkId() {
NeutronNetwork neutronNetwork = mock(NeutronNetwork.class);
- List<NeutronNetwork> listNeutronNetwork = new ArrayList<NeutronNetwork>();
+ List<NeutronNetwork> listNeutronNetwork = new ArrayList<>();
listNeutronNetwork.add(neutronNetwork);
when(neutronNetwork.getProviderSegmentationID()).thenReturn("segId");
@Before
public void setUp(){
when(southbound.getOvsdbNodeUUID(any(Node.class))).thenReturn(NODE_UUID);
- List<OvsdbTerminationPointAugmentation> ports = new ArrayList<OvsdbTerminationPointAugmentation>();
+ List<OvsdbTerminationPointAugmentation> ports = new ArrayList<>();
OvsdbTerminationPointAugmentation port = mock(OvsdbTerminationPointAugmentation.class);
VlanId vlanId = mock(VlanId.class);
when(vlanId.getValue()).thenReturn(VLAN_ID);
-define(['app/ovsdb/lib/d3.min', 'app/ovsdb/OvsCore', 'underscore'], function(d3, OvsCore, _) {
+define(['app/ovsdb/lib/d3.min', 'app/ovsdb/OvsCore', 'underscore'], function (d3, OvsCore, _) {
'use strict';
var root = null,
canvasWidth = -1,
canvasHeight = -1,
- bbox = { x:0, y:15, width: 0, height: 0},
+ bbox = {
+ x: 0,
+ y: 15,
+ width: 0,
+ height: 0
+ },
// config
nodeWidth = 15,
nodeHeight = -1,
- defaultRouterWidth = 66,
- defaultRouterHeight = 66,
- networkMargin = { width: 120, height: 15},
- routerMargin = { width: 120, height: 40},
- vmMargin = { width: 90, height: 30},
+ defaultRouterWidth = 52,
+ defaultRouterHeight = 52,
+ networkMargin = {
+ width: 120,
+ height: 15
+ },
+ routerMargin = {
+ width: 120,
+ height: 40
+ },
+ vmMargin = {
+ width: 90,
+ height: 30
+ },
defaultVmsWidth = 48,
defaultVmsHeight = 48,
ipNetworkTextMaxLength = 60,
d3Router = null,
randomize = OvsCore.Util.Math.Random(42);
- function LogicalGraph(id, width , height) {
+ function LogicalGraph(id, width, height) {
canvasWidth = width;
canvasHeight = height;
nodeHeight = height - 15;
var tmp = d3.select(id).append("svg")
- .attr('width', width)
- .attr('height', height)
- .append("svg:g")
- .attr('class', 'layer_0');
+ .attr('width', width)
+ .attr('height', height)
+ .append("svg:g")
+ .attr('class', 'layer_0');
tmp.append('svg:rect')
- .attr('width', width)
- .attr('height', height)
- .attr('fill', 'white');
+ .attr('width', width)
+ .attr('height', height)
+ .attr('fill', 'white');
root = tmp.call(d3.behavior.zoom().scaleExtent([1, 8]).on("zoom", zoom))
- .append("g");
+ .append("g");
tmp.on("dblclick.zoom", null);
addDefs();
}
var defs = d3.select('svg').insert('svg:defs', ':first-child');
var filter = defs.append('svg:filter').attr('id', 'boxShadow').attr('x', '0').attr('y', '0').attr('width', '200%').attr('height', '200%');
filter.append('feOffset').attr('in', 'SourceAlpha').attr('result', 'offOut').attr('dx', 0).attr('dy', 0);
- filter.append('feGaussianBlur').attr('stdDeviation', '5').attr('in','offOut').attr('result', 'blurOut');
+ filter.append('feGaussianBlur').attr('stdDeviation', '5').attr('in', 'offOut').attr('result', 'blurOut');
filter.append('feOffset').attr('in', 'SourceGraphic').attr('in2', 'blurOut').attr('mode', 'normal');
}
Object.defineProperties(LogicalGraph.prototype, {
networks: {
- set: function(value) {
+ set: function (value) {
networkData = value;
- value.forEach(function(net) {
+ value.forEach(function (net) {
routerData = routerData.concat(net.routers);
});
- value.forEach(function(net) {
+ value.forEach(function (net) {
vmData = vmData.concat(net.instances);
});
}
}
});
- LogicalGraph.prototype.start = function() {
+ LogicalGraph.prototype.start = function () {
setTopologyPosition.call(this, networkData);
addLinksToDom.call(this, linkData);
addNetWorkRouterVmsToDom.call(this, networkData, routerData, vmData);
update.call(this);
};
- LogicalGraph.prototype.freeDOM = function() {
+ LogicalGraph.prototype.freeDOM = function () {
d3Node.remove();
d3Link.remove();
d3Vm.remove();
routerData = [];
vmData = [];
linkData = [];
- bbox = { x:0, y:15, width: 0, height: 0};
+ bbox = {
+ x: 0,
+ y: 15,
+ width: 0,
+ height: 0
+ };
};
function addLinksToDom(linksData) {
- d3Link = root.selectAll('.llink')
+ d3Link = root.selectAll('.llink')
.data(linksData).enter().append('svg:g');
- d3Link.append('rect')
- .attr('width', function(d) {
+ d3Link.append('rect')
+ .attr('width', function (d) {
return d.target.x - d.source.x;
})
.attr('height', linkHeight)
- .style('fill', function(d) {
+ .style('fill', function (d) {
return d.color;
});
- d3Link.append('text')
+ d3Link.append('text')
.attr('x', 40)
.attr('y', -3)
- .text(function(d) {return d.text;});
+ .text(function (d) {
+ return d.text;
+ });
}
function addNetWorkRouterVmsToDom(networks, routers, vms) {
var ctx = this,
timer = null;
- function getAbsPos() {
- var elem = d3.select(this)[0][0],
- elemAbsBBox = elem.getBoundingClientRect(),
- parentAbsBox = d3.select('#l_graph').node().getBoundingClientRect(),
- left = elemAbsBBox.left - parentAbsBox.left + (elemAbsBBox.right - elemAbsBBox.left),
- top = elemAbsBBox.top - parentAbsBox.top;
-
- if (top < 0 ) {
- top = 10;
- }
- var event = {
- left : left,
- top : top
- };
- return event;
- }
d3Node = root.selectAll('.network')
.data(networks).enter()
.append('svg:g');
.attr('height', nodeHeight)
.attr('rx', 10)
.attr('ry', 10)
- .style('fill', function(d) {
+ .style('fill', function (d) {
return d.color;
- }).on('click', function(d) {
+ }).on('click', function (d) {
if (d3.event.defaultPrevented) return;
- timer = setTimeout(function() {
- var e = getAbsPos.call(this);
- ctx.onClick(e, d);
+ timer = setTimeout(function () {
+ ctx.onClick(d);
}.bind(this), 150);
- }).on('dblclick', function(d) {
+ }).on('dblclick', function (d) {
clearTimeout(timer);
ctx.dblClick(d);
});
// append the network name text
d3Node.append('text')
- .attr('x', nodeWidth / 2 )
- .attr('y', nodeHeight /2 )
+ .attr('x', nodeWidth / 2)
+ .attr('y', nodeHeight / 2)
.style('text-anchor', 'middle')
.style('writing-mode', 'tb')
.style('font-size', '12px')
.style('glyph-orientation-vertical', '0')
- .text(function(d) { return d.name; });
+ .text(function (d) {
+ return d.name;
+ });
// text info for the network ip
d3Node.append('text')
.attr('transform',
OvsCore.Util.String.Format('translate({0} {1}) rotate(-90) translate(-{0} -{1})', nodeWidth + 10, nodeHeight - 15))
.attr('class', 'linfolabel')
- .text(function(d) {return d.ip;});
+ .text(function (d) {
+ return d.ip;
+ });
// vm
d3Vm.append('svg:image')
.attr('width', defaultVmsWidth)
.attr('height', defaultVmsHeight)
.attr('filter', 'url(#boxShadow)')
- .attr('xlink:href', function(d) {
+ .attr('xlink:href', function (d) {
return d.type === 'network:dhcp' ?
'src/app/ovsdb/assets/dhcp.png' : 'src/app/ovsdb/assets/vm.png';
})
- .on('click', function(d) {
+ .on('click', function (d) {
if (d3.event.defaultPrevented) return;
- timer = setTimeout(function() {
- var e = getAbsPos.call(this);
- ctx.onClick(e, d);
+ timer = setTimeout(function () {
+ ctx.onClick(d);
}.bind(this), 150);
- }).on('dblclick', function(d) {
+ }).on('dblclick', function (d) {
clearTimeout(timer);
ctx.dblClick(d);
});
.attr('width', defaultRouterWidth)
.attr('height', defaultRouterHeight)
.attr('xlink:href', 'src/app/ovsdb/assets/router.png')
- .on('click', function(d) {
+ .on('click', function (d) {
if (d3.event.defaultPrevented) return;
- timer = setTimeout(function() {
- var e = getAbsPos.call(this);
- ctx.onClick(e, d);
+ timer = setTimeout(function () {
+ ctx.onClick(d);
}.bind(this), 150);
- }).on('dblclick', function(d) {
+ }).on('dblclick', function (d) {
clearTimeout(timer);
ctx.dblClick(d);
});
.attr('y', defaultRouterHeight + 15)
.attr('text-anchor', 'middle')
.attr('class', 'linfolabel')
- .text(function(d) { return d.name; });
+ .text(function (d) {
+ return d.name;
+ });
// vm name label
d3Vm.append('text')
.attr('y', defaultVmsHeight + 15)
.attr('text-anchor', 'middle')
.attr('class', 'linfolabel')
- .text(function(d) { return d.name; });
+ .text(function (d) {
+ return d.name;
+ });
// vm floating ip label
d3Vm.append('text')
.attr('x', -35)
.attr('y', 40)
.attr('text-anchor', 'middle')
- .text(function(d) {
+ .text(function (d) {
return (d.floatingIp) ? d.floatingIp.ip : '';
});
function findNetworkWithRouter(router) {
var result = [];
- _.each(router.interfaces, function(inter) {
+ _.each(router.interfaces, function (inter) {
if (inter.type === 'router_interface') {
- var net = tmpNetHolder[inter.networkId] || null;
+ var net = tmpNetHolder[inter.networkId] || null;
if (net) {
- result.push({network: net, interface: inter});
+ result.push({
+ network: net,
+ interface: inter
+ });
}
}
});
network.color = d3.hsl(randomize.next() * 360, 1, 0.6).toString();
// look is the network is the highest
- bbox.height = network.y > bbox.height ? network.y : bbox.height ;
+ bbox.height = network.y > bbox.height ? network.y : bbox.height;
bbox.width = network.x > bbox.width ? network.x : bbox.width;
// get the number of "childs" (router, vm)
var nbVm = network.instances.length;
if (!network.external) {
- _.each(network.subnets, function(subnet, i) {
+ _.each(network.subnets, function (subnet, i) {
network.ip += subnet.cidr;
- if (i < network.subnets.length -1) {
- network.ip += ', ';
+ if (i < network.subnets.length - 1) {
+ network.ip += ', ';
}
});
}
function positionateRouter(network, x, y) {
var px = x,
- py = y ;
+ py = y;
// loop over all routers
- _.each(network.routers, function(router, i) {
- router.x = getRouterCentroid(x, py).x ;
+ _.each(network.routers, function (router, i) {
+ router.x = getRouterCentroid(x, py).x;
router.y = py;
py += getRouterMarginHeight();
}
// look is the router is the highest
- bbox.height = router.y > bbox.height ? router.y : bbox.height ;
+ bbox.height = router.y > bbox.height ? router.y : bbox.height;
bbox.width = router.x > bbox.width ? router.x : bbox.width;
linkData.push({
- source: {x: network.x + (nodeWidth * 0.5), y: router.y + (defaultRouterHeight * 0.5)},
- target: {x: router.x + (defaultRouterWidth * 0.5), y: router.y + (nodeWidth * 0.5)},
- color: network.color,
+ source: {
+ x: network.x + (nodeWidth * 0.5),
+ y: router.y + (defaultRouterHeight * 0.5)
+ },
+ target: {
+ x: router.x + (defaultRouterWidth * 0.5),
+ y: router.y + (nodeWidth * 0.5)
+ },
+ color: network.color,
text: router.externalGateway.external_fixed_ips[0].ip_address
});
var nets = findNetworkWithRouter(router),
step = defaultRouterHeight / (nets.length + 1);
- _.forEach(nets, function(net, i) {
+ _.forEach(nets, function (net, i) {
var netPos = getNetworkLayerPosition(bbox.width + defaultRouterWidth);
positionateNetwork(net.network, netPos.x, netPos.y);
linkData.push({
- source: {x: router.x + (2 * nodeWidth), y: router.y + step * (i + 1) },
- target: {x: net.network.x + (nodeWidth * 0.5), y: router.y + (nodeWidth * 0.5 )},
+ source: {
+ x: router.x + (2 * nodeWidth),
+ y: router.y + step * (i + 1)
+ },
+ target: {
+ x: net.network.x + (nodeWidth * 0.5),
+ y: router.y + (nodeWidth * 0.5)
+ },
color: net.network.color,
text: net.interface.ip.ip_address
});
// I do vm before router because router
// will step to another BUS
- _.each(network.instances, function(vm) {
+ _.each(network.instances, function (vm) {
vm.x = x;
vm.y = y;
// look is the network is the highest
- bbox.height = vm.y > bbox.height ? vm.y : bbox.height ;
+ bbox.height = vm.y > bbox.height ? vm.y : bbox.height;
bbox.width = vm.x > bbox.width ? vm.x : bbox.width;
y += getVmMarginHeight();
linkData.push({
- source: {x: network.x + (nodeWidth * 0.5), y: vm.y + (defaultVmsHeight * 0.5 )},
- target: {x: vm.x + (defaultVmsWidth * 0.5), y: vm.y + (nodeWidth * 0.5)},
- color: network.color,
+ source: {
+ x: network.x + (nodeWidth * 0.5),
+ y: vm.y + (defaultVmsHeight * 0.5)
+ },
+ target: {
+ x: vm.x + (defaultVmsWidth * 0.5),
+ y: vm.y + (nodeWidth * 0.5)
+ },
+ color: network.color,
text: vm.ip
});
});
}
/*
- * Scan the whole "BUS" to display it properly
- * ------------------------------------------------
- * I build it in a virtual space, if it need to be
- * resize it at the end when the overal bounding
- * box is known
- */
+ * Scan the whole "BUS" to display it properly
+ * ------------------------------------------------
+ * I build it in a virtual space, if it need to be
+ * resize it at the end when the overal bounding
+ * box is known
+ */
function setTopologyPosition(networks) {
- _.each(networks, function(net) {
+ _.each(networks, function (net) {
tmpNetHolder[net.id] = net;
});
var i = 0;
- for(var key in tmpNetHolder) {
- var margin = (i === 0) ? 5 : networkMargin.width,
- net = tmpNetHolder[key];
- if (net.routers.length > 0) {
- positionateNetwork(net, bbox.x + bbox.width + margin, bbox.y);
- ++i;
- }
+ for (var key in tmpNetHolder) {
+ var margin = (i === 0) ? 5 : networkMargin.width,
+ net = tmpNetHolder[key];
+ if (net.routers.length > 0) {
+ positionateNetwork(net, bbox.x + bbox.width + margin, bbox.y);
+ ++i;
+ }
}
- for(var key in tmpNetHolder) {
- var margin = networkMargin.width,
- net = tmpNetHolder[key];
- positionateNetwork(net, bbox.x + bbox.width + margin, bbox.y);
+ for (var key in tmpNetHolder) {
+ var margin = networkMargin.width,
+ net = tmpNetHolder[key];
+ positionateNetwork(net, bbox.x + bbox.width + margin, bbox.y);
}
}
/*
- * Check and ajust the height for a network.
- */
+ * Check and ajust the height for a network.
+ */
function ajustHeighBaseOnChilds(nbRouter, nbVm) {
// calculate the height for the number of childs
var childHeight = nbRouter * (getRouterMarginHeight()) +
}
/*
- * Set the view to the modal position
- */
+ * Set the view to the modal position
+ */
function update() {
- d3Node.attr('transform', function(d) {
+ d3Node.attr('transform', function (d) {
return OvsCore.Util.String.Format("translate({0}, {1})",
d.x, d.y
);
});
- d3Router.attr('transform', function(d, i) {
+ d3Router.attr('transform', function (d, i) {
return OvsCore.Util.String.Format("translate({0}, {1})",
d.x, d.y
);
});
- d3Vm.attr('transform', function(d) {
+ d3Vm.attr('transform', function (d) {
return OvsCore.Util.String.Format("translate({0}, {1})",
d.x, d.y
);
});
- d3Link.attr('transform', function(d) {
+ d3Link.attr('transform', function (d) {
return OvsCore.Util.String.Format("translate({0}, {1})",
d.source.x, d.source.y
);
function getRouterCentroid(x, y) {
return {
- x : x + defaultRouterWidth * 0.5,
- y : y + defaultRouterHeight * 0.5
+ x: x + defaultRouterWidth * 0.5,
+ y: y + defaultRouterHeight * 0.5
};
}
function getNetworkLayerPosition(x) {
return {
- x : x + networkMargin.width,
- y : networkMargin.height
+ x: x + networkMargin.width,
+ y: networkMargin.height
};
}
function getVmLayerPosition(nbRouter, x) {
- var t = {
- x : x + vmMargin.width * 2,
- y : getRoutersDim(nbRouter).height + getVmMarginHeight()
+ var t = {
+ x: x + vmMargin.width * 2,
+ y: getRoutersDim(nbRouter).height + getVmMarginHeight()
};
return t;
}
}
},
nodes: {
- get: function() {
+ get: function () {
return _.extend({}, this._bridgeNodes, this._ovsdbNodes);
}
},
Topology.prototype.updateLink = function () {
_.each(this._links, (function (link, key) {
if (link instanceof Link) {
- srcNode = _.filter(this._bridgeNodes, function(node) {
+ srcNode = _.filter(this._bridgeNodes, function (node) {
return node.getFLowName() === link.srcNodeId;
});
- destNode = _.filter(this._bridgeNodes, function(node) {
+ destNode = _.filter(this._bridgeNodes, function (node) {
return node.getFLowName() === link.destNodeId;
});
link.srcNodeId = srcNode[0].nodeId;
this.ovsVersion = ovsVersion;
}
- OvsNode.prototype.showIpAdress = function() {
+ OvsNode.prototype.showIpAdress = function () {
return this.otherLocalIp;
};
- OvsNode.prototype.pretty = function() {
+ OvsNode.prototype.pretty = function () {
return {
- 'tabs' : ['Info'],
- 'containts' : [ {
- 'hasHeader' : false,
- 'headers' : [],
- 'datas' : [
- { key: 'ID', value: this.nodeId},
- { key: 'InetMgr', value: this.inetMgr},
- { key: 'InetNode', value: this.inetNode},
- { key: 'Local IP', value: this.otherLocalIp},
- { key: 'OVS Version', value: this.ovsVersion}
+ 'tabs': ['Info'],
+ 'containts': [{
+ 'hasHeader': false,
+ 'headers': [],
+ 'datas': [
+ {
+ key: 'ID',
+ value: this.nodeId
+ },
+ {
+ key: 'InetMgr',
+ value: this.inetMgr
+ },
+ {
+ key: 'InetNode',
+ value: this.inetNode
+ },
+ {
+ key: 'Local IP',
+ value: this.otherLocalIp
+ },
+ {
+ key: 'OVS Version',
+ value: this.ovsVersion
+ }
]
}]
};
BridgeNode.prototype.addTerminationPoint = function (tp) {
this._tpList.push(tp);
- this._tpList.sort(function(tp1, tp2) {
+ this._tpList.sort(function (tp1, tp2) {
return tp1.ofPort - tp2.ofPort;
});
};
- BridgeNode.prototype.addFlowTableInfo = function(flowTable) {
+ BridgeNode.prototype.addFlowTableInfo = function (flowTable) {
this.flowTable.push(flowTable);
- this.flowTable.sort(function(ft1, ft2) {
+ this.flowTable.sort(function (ft1, ft2) {
return ft1.key - ft2.key;
});
};
- BridgeNode.prototype.pretty = function() {
+ BridgeNode.prototype.pretty = function () {
return {
- 'tabs' : [
+ 'tabs': [
'Basic Info',
'Ports',
'Flow Info',
'Flow Tables'
],
- 'containts' : [
+ 'containts': [
{
- 'hasHeader' : false,
- 'headers' : [],
- 'datas' : [
- { key: 'ID', value: this.nodeId},
- { key: 'Name', value: this.name},
- { key: 'OpenFlow Name', value: this.getFLowName()},
- { key: 'Controller Target', value: this.controllerTarget},
- { key: 'Controller Connected', value: this.controllerConnected}
+ 'hasHeader': false,
+ 'headers': [],
+ 'datas': [
+ {
+ key: 'ID',
+ value: this.nodeId
+ },
+ {
+ key: 'Name',
+ value: this.name
+ },
+ {
+ key: 'OpenFlow Name',
+ value: this.getFLowName()
+ },
+ {
+ key: 'Controller Target',
+ value: this.controllerTarget
+ },
+ {
+ key: 'Controller Connected',
+ value: this.controllerConnected
+ }
]
},
{
- 'hasHeader' : true,
- 'header' : ['Of Port', 'Name', 'Mac', 'IFace Id',],
- 'datas' : this._tpList.map(function(s) {
+ 'hasHeader': true,
+ 'header': ['Of Port', 'Name', 'Mac', 'IFace Id', ],
+ 'datas': this._tpList.map(function (s) {
return [s.ofPort, s.name, s.mac, s.ifaceId];
})
},
{
- 'hasHeader' : false,
- 'headers' : [],
- 'datas': [
- {key : 'Manufacturer', value: this.flowInfo.manufacturer},
- {key : 'Hardware', value: this.flowInfo.hardware},
- {key : 'Software', value: this.flowInfo.software},
- {key : 'Feature', value: this.flowInfo.features},
- {key : 'Ip', value: this.flowInfo.ip}
+ 'hasHeader': false,
+ 'headers': [],
+ 'datas': [
+ {
+ key: 'Manufacturer',
+ value: this.flowInfo.manufacturer
+ },
+ {
+ key: 'Hardware',
+ value: this.flowInfo.hardware
+ },
+ {
+ key: 'Software',
+ value: this.flowInfo.software
+ },
+ {
+ key: 'Feature',
+ value: this.flowInfo.features
+ },
+ {
+ key: 'Ip',
+ value: this.flowInfo.ip
+ }
]
},
{
- 'hasHeader' : true,
- 'headers' : ['Table Id', 'Value'],
- 'datas' :this.flowTable.map(function(t) {
+ 'hasHeader': true,
+ 'headers': ['Table Id', 'Value'],
+ 'datas': this.flowTable.map(function (t) {
return [t.key, t.value];
})
}
return TerminationPoint;
})();
- var BaseLink = (function() {
+ var Tunnel = (function () {
+ function Tunnel(name, ofPort, tpType, mac, ifaceId, localIp, remoteIp) {
+ TerminationPoint.call(this, name, ofPort, tpType, mac, ifaceId);
+ this.localIp = localIp;
+ this.remoteIp = remoteIp;
+ }
+ Tunnel.prototype = Object.create(TerminationPoint.prototype);
+ Tunnel.prototype.constructor = Tunnel;
+
+ return Tunnel;
+ })();
+
+ var BaseLink = (function () {
function BaseLink(linkId, srcNodeId, destNodeId, linkType, styles) {
this.linkId = linkId;
this.srcNodeId = srcNodeId;
this.destNodeId = destNodeId;
- this.linkType = linkType;
+ this.linkType = linkType;
// styling
styles = _.extend({}, styles);
return Link;
})();
- var TunnelLink = (function() {
+ var TunnelLink = (function () {
function TunnelLink(linkId, srcNodeId, destNodeId, linkType, color) {
var opt = {
color: 'green',
return TunnelLink;
})();
- var BridgeOvsLink = (function() {
+ var BridgeOvsLink = (function () {
function BridgeOvsLink(linkId, srcNodeId, destNodeId, linkType, color) {
var opt = {
color: 'gray',
return BridgeOvsLink;
})();
- var Util = (function() {
- var Maths = (function() {
+ var Util = (function () {
+ var Maths = (function () {
function Maths() {
}
// random function in javascript use timespan only
- Maths.Random = function(nseed) {
- var constant = Math.pow(2, 13)+1,
+ Maths.Random = function (nseed) {
+ var constant = Math.pow(2, 13) + 1,
prime = 1987,
maximum = 1000;
- if (nseed) {
- seed = nseed;
- }
+ if (nseed) {
+ seed = nseed;
+ }
- return {
- next : function(min, max) {
- seed *= constant;
- seed += prime;
+ return {
+ next: function (min, max) {
+ seed *= constant;
+ seed += prime;
- return min && max ? min+seed%maximum/maximum*(max-min) : seed%maximum/maximum;
- }
- };
+ return min && max ? min + seed % maximum / maximum * (max - min) : seed % maximum / maximum;
+ }
+ };
};
return Maths;
})();
- var String = (function() {
+ var String = (function () {
function String() {
}
- String.Format = function() {
+ String.Format = function () {
var s = arguments[0];
for (var i = 0; i < arguments.length - 1; i++) {
- var reg = new RegExp("\\{" + i + "\\}", "gm");
- s = s.replace(reg, arguments[i + 1]);
+ var reg = new RegExp("\\{" + i + "\\}", "gm");
+ s = s.replace(reg, arguments[i + 1]);
}
return s;
};
};
})();
- var Neutron = (function() {
+ var Neutron = (function () {
- var SubNet = (function() {
+ var SubNet = (function () {
function SubNet(id, networkId, name, ipVersion, cidr, gatewayIp, tenantId) {
this.id = id;
this.networkId = networkId;
return SubNet;
})();
- var Network = (function() {
+ var Network = (function () {
function Network(id, name, shared, status, external, tenantId) {
this.id = id;
this.ip = '';
this.routers = [];
}
- Network.prototype.addSubNets = function(subnets) {
- if(subnets) {
+ Network.prototype.addSubNets = function (subnets) {
+ if (subnets) {
if (_.isArray(subnets)) {
var i = 0;
for (; i < subnets.length; ++i) {
this.subnets.push(subnets[i]);
}
- }
- else {
+ } else {
this.subnets.push(subnet);
}
}
};
- Network.prototype.asSubnet = function(subnet) {
- return _.every(subnet, function(sub) {
- return _.some(this.subnets, function(s) {
+ Network.prototype.asSubnet = function (subnet) {
+ return _.every(subnet, function (sub) {
+ return _.some(this.subnets, function (s) {
return s.id === sub;
});
}.bind(this));
};
- Network.prototype.pretty = function() {
+ Network.prototype.pretty = function () {
return {
- 'tabs' : [
+ 'tabs': [
'Info',
'Subnets'
],
- 'containts' : [
+ 'containts': [
{
- 'hasHeader' : false,
+ 'hasHeader': false,
'headers': [],
- 'datas' : [
- {key : 'ID', value: this.id},
- {key : 'Ip', value: this.ip},
- {key : 'Name', value: this.name},
- {key : 'Shared', value: this.shared},
- {key : 'Status', value: this.status},
- {key : 'External', value: this.external},
- {key : 'Tenant Id', value: this.tenantId}
+ 'datas': [
+ {
+ key: 'ID',
+ value: this.id
+ },
+ {
+ key: 'Ip',
+ value: this.ip
+ },
+ {
+ key: 'Name',
+ value: this.name
+ },
+ {
+ key: 'Shared',
+ value: this.shared
+ },
+ {
+ key: 'Status',
+ value: this.status
+ },
+ {
+ key: 'External',
+ value: this.external
+ },
+ {
+ key: 'Tenant Id',
+ value: this.tenantId
+ }
]
},
{
- 'hasHeader' : true,
- 'header' : ['ID', 'Name', 'Ip Version', 'Ip', 'Gateway Ip'],
- 'datas' : this.subnets.map(function(s) {
+ 'hasHeader': true,
+ 'header': ['ID', 'Name', 'Ip Version', 'Ip', 'Gateway Ip'],
+ 'datas': this.subnets.map(function (s) {
return [s.id, s.name, s.ipVersion, s.cidr, s.gatewayIp];
})
}
return Network;
})();
- var Port = (function() {
+ var Port = (function () {
function Port(id, networkId, name, tenantId, deviceId, deviceOwner, fixed_ips, mac) {
this.id = id;
this.networkId = networkId;
this.mac = mac;
}
- Port.prototype.pretty = function() {
+ Port.prototype.pretty = function () {
return [
- { key: 'ID', value : this.id },
- { key: 'Name', value: name },
- { key: 'Tenant Id', value : this.tenantId },
- { key: 'Device Id', value : this.deviceId },
- { key: 'Device Owner', value : this.deviceOwner },
- { key: 'MAC', value : this.mac }
+ {
+ key: 'ID',
+ value: this.id
+ },
+ {
+ key: 'Name',
+ value: name
+ },
+ {
+ key: 'Tenant Id',
+ value: this.tenantId
+ },
+ {
+ key: 'Device Id',
+ value: this.deviceId
+ },
+ {
+ key: 'Device Owner',
+ value: this.deviceOwner
+ },
+ {
+ key: 'MAC',
+ value: this.mac
+ }
];
};
return Port;
})();
- var Router = (function() {
+ var Router = (function () {
function Router(id, name, status, tenantId, externalGateway) {
this.id = id;
this.name = name;
this.externalGateway = externalGateway;
}
- Router.prototype.pretty = function() {
+ Router.prototype.pretty = function () {
return {
- 'tabs' : [
+ 'tabs': [
'Info',
'Interfaces'
],
- 'containts' : [
+ 'containts': [
{
- 'hasHeader' : false,
+ 'hasHeader': false,
'headers': [],
- 'datas' : [
- { key: 'ID', value: this.id},
- { key: 'Name', value: this.name},
- { key: 'status', value: this.status},
- { key: 'Tenant ID', value: this.tenantId}
+ 'datas': [
+ {
+ key: 'ID',
+ value: this.id
+ },
+ {
+ key: 'Name',
+ value: this.name
+ },
+ {
+ key: 'status',
+ value: this.status
+ },
+ {
+ key: 'Tenant ID',
+ value: this.tenantId
+ }
]
},
{
- 'hasHeader' : true,
- 'header' : ['ID', 'Type', 'Mac Address', 'Ip', 'Tenant Id'],
- 'datas' : this.interfaces.map(function(s) {
+ 'hasHeader': true,
+ 'header': ['ID', 'Type', 'Mac Address', 'Ip', 'Tenant Id'],
+ 'datas': this.interfaces.map(function (s) {
return [s.id, s.type, s.mac, s.ip.ip_address, s.tenantId];
})
}
return Router;
})();
- var Instance = (function() {
+ var Instance = (function () {
function Instance(id, networkId, name, ip, mac, deviceOwner, tenantId, topoInfo) {
this.id = id;
this.networkId = networkId;
this.floatingIp = {};
}
- Instance.prototype.extractFloatingIps = function(floatingIps) {
+ Instance.prototype.extractFloatingIps = function (floatingIps) {
var ctx = this;
- this.floatingIp = _.find(floatingIps, function(fIp) {
+ this.floatingIp = _.find(floatingIps, function (fIp) {
return fIp.tenantId === ctx.tenantId &&
fIp.fixedIp === ctx.ip;
});
};
- Instance.prototype.pretty = function() {
+ Instance.prototype.pretty = function () {
return {
- 'tabs' : [
+ 'tabs': [
'Info',
'Ports'
],
- 'containts' : [
+ 'containts': [
{
- 'hasHeader' : false,
+ 'hasHeader': false,
'headers': [],
- 'datas' : [
- { key: 'ID', value: this.id},
- { key: "Network Id", value : this.networkId},
- { key: 'Name', value: this.name},
- { key: 'Ip', value: this.ip},
- { key: 'Floating Ip', value: (this.floatingIp) ? this.floatingIp.ip : 'Not found' },
- { key: 'MAC', value: this.mac},
- { key: 'Type', value: this.type},
- { key: 'Tenant ID', value: this.tenantId}
+ 'datas': [
+ {
+ key: 'ID',
+ value: this.id
+ },
+ {
+ key: "Network Id",
+ value: this.networkId
+ },
+ {
+ key: 'Name',
+ value: this.name
+ },
+ {
+ key: 'Ip',
+ value: this.ip
+ },
+ {
+ key: 'Floating Ip',
+ value: (this.floatingIp) ? this.floatingIp.ip : 'Not found'
+ },
+ {
+ key: 'MAC',
+ value: this.mac
+ },
+ {
+ key: 'Type',
+ value: this.type
+ },
+ {
+ key: 'Tenant ID',
+ value: this.tenantId
+ }
]
},
{
- 'hasHeader' : true,
- 'header' : ['Name', 'Of Port', 'Mac', 'Flow', 'Ovsdb Node', 'Ovsdb Node IP'],
- 'datas' : this.topoInfo.map(function(s) {
+ 'hasHeader': true,
+ 'header': ['Name', 'Of Port', 'Mac', 'Flow', 'Ovsdb Node', 'Ovsdb Node IP'],
+ 'datas': this.topoInfo.map(function (s) {
return [s.name, s.ofPort, s.mac, s.bridge.getFLowName(), s.ovsNode.nodeId, s.ovsNode.showIpAdress()];
})
}
return Instance;
})();
- var FloatingIp =(function() {
+ var FloatingIp = (function () {
function FloatingIp(id, networkId, portId, fixedIp, floatingIp, tentantId, status) {
this.id = id;
this.networkId = networkId;
BridgeNode: BridgeNode,
TerminationPoint: TerminationPoint,
Topology: Topology,
+ Tunnel: Tunnel,
BaseLink: BaseLink,
Link: Link,
TunnelLink: TunnelLink,
- BridgeOvsLink:BridgeOvsLink,
- Util:Util,
+ BridgeOvsLink: BridgeOvsLink,
+ Util: Util,
Neutron: Neutron
};
});
-define(['app/ovsdb/ovsdb.module'], function(ovsdb) {
+define(['app/ovsdb/ovsdb.module'], function (ovsdb) {
ovsdb.register.constant('nodeIdentifier', {
IP: 'ip',
ID: 'link-id',
DEST: 'destination'
});
+
+ ovsdb.register.constant('OVSConstant', {
+ TP_TYPE: {
+ INTERNAL: 'ovsdb:interface-type-internal',
+ VXLAN: 'ovsdb:interface-type-vxlan'
+ }
+ })
+
});
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-define(['app/ovsdb/ovsdb.module', 'app/ovsdb/lib/d3.min', 'app/ovsdb/Graph', 'app/ovsdb/LogicalGraph','app/ovsdb/OvsCore', 'underscore', 'jquery', 'jquery-ui'], function (ovsdb, d3, Graph, LogicalGraph, OvsCore, _, $) {
+define(['app/ovsdb/ovsdb.module', 'app/ovsdb/lib/d3.min', 'app/ovsdb/Graph', 'app/ovsdb/LogicalGraph', 'app/ovsdb/OvsCore', 'underscore', 'jquery', 'jquery-ui'], function (ovsdb, d3, Graph, LogicalGraph, OvsCore, _, $) {
'use strict';
- ovsdb.register.directive('logicalGraph', function() {
+ ovsdb.register.directive('logicalGraph', function () {
return {
restrict: 'EA',
scope: false,
- link : function (scope, elem, attr) {
+ link: function (scope, elem, attr) {
var lgraph = null,
- tabCreated = false,
- width = scope.canvasWidth, //ele[0].clientWidth,
- height = scope.canvasHeight;
+ tabCreated = false,
+ width = scope.canvasWidth, //ele[0].clientWidth,
+ height = scope.canvasHeight;
scope.lDialogData = {};
- scope.lgraphIsReadyPromise.then(function(ltopo) {
+ scope.lgraphIsReadyPromise.then(function (ltopo) {
if (!lgraph) {
lgraph = new LogicalGraph(elem[0], width, height);
}
lgraph.start();
- lgraph.onClick = function(e, d) {
+ lgraph.onClick = function (d) {
var dialogId = '#lDialog';
scope.lDialogData = d.pretty();
scope.$apply();
$(dialogId).tabs();
$(dialogId).draggable({
containment: 'parent',
- cancel:'.window_content'
+ cancel: '.window_content'
});
tabCreated = true;
} else {
$(dialogId).tabs('refresh');
}
- var $dia = $(dialogId);
- $dia.css('left', e.left + 30);
- $dia.css('top', e.top + 35);
+ var $dia = $(dialogId),
+ left = $dia.css('left'),
+ top = $dia.css('top') || e.top + 35;
+ $dia.css('left', left !== 'auto' ? left : 10);
+ $dia.css('top', top !== 'auto' ? top : 10);
$dia.show();
};
- lgraph.dblClick = function(d) {
+ lgraph.dblClick = function (d) {
scope.goToPhysicalView(d);
};
});
- scope.hideLogicalDialog = function() {
- $('#lDialog').tabs("option", "active", 0)
+ scope.hideLogicalDialog = function () {
+ $('#lDialog').tabs("option", "active", 0)
.hide();
};
elem.on('$destroy', function () {
});
links.style("stroke", function (o) {
- return ((o.source.index == d.index || o.target.index == d.index) && o.linkType != 'tunnel') ? "blue" : o.color;
+ return ((o.source.index == d.index || o.target.index == d.index) && o.linkType != 'tunnel') ? "blue" : o.color;
});
};
graph.onNodeOut = function (d, nodes, links) {
nodes.selectAll('.switch > rect').style("stroke", "black");
- links.style("stroke", function(o) { return o.color; });
+ links.style("stroke", function (o) {
+ return o.color;
+ });
};
graph.onNodeClick = function (d, nodes, links, ctx) {
$(dialogId).tabs();
$(dialogId).draggable({
containment: 'parent',
- cancel:'.window_content'
+ cancel: '.window_content'
});
tabCreated = true;
} else {
$(dialogId).tabs('refresh');
}
- $dia.css('left', /*e.left + */30);
- $dia.css('top', /*e.top + */35);
+ $dia.css('left', /*e.left + */ 30);
+ $dia.css('top', /*e.top + */ 35);
$dia.show();
};
});
- ele.on('$destroy', function() {
+ ele.on('$destroy', function () {
graph.freeDOM();
});
- scope.hidePhysicalDialog = function() {
+ scope.hidePhysicalDialog = function () {
$('#pDialog').tabs("option", "active", 0)
- .hide();
+ .hide();
};
scope.rotateGraph = function (value) {
$('path.tunnel').toggle();
};
- scope.filterNode = function(nodeIds, tags, exclude) {
+ scope.filterNode = function (nodeIds, tags, exclude) {
exclude = (exclude === null) ? true : exclude;
var nodes = d3.selectAll(tags);
- nodes.each(function(d) {
- if (nodeIds.indexOf(d.node.nodeId) < 0) {
- d.hidden = exclude;
- } else {
- d.hidden = !exclude;
- }
- });
- nodes.transition().duration(200).style('opacity', function(d) {
- return d.hidden ? '0.3' : '1';
+ nodes.each(function (d) {
+ if (nodeIds.indexOf(d.node.nodeId) < 0) {
+ d.hidden = exclude;
+ } else {
+ d.hidden = !exclude;
+ }
+ });
+ nodes.transition().duration(200).style('opacity', function (d) {
+ return d.hidden ? '0.3' : '1';
});
};
- scope.filterLink = function() {
+ scope.filterLink = function () {
var links = d3.selectAll(".tunnel, .link, .bridgeOvsLink");
- links.each(function(d, i) {
+ links.each(function (d, i) {
d.hidden = d.source.hidden || d.target.hidden;
});
- links.transition().duration(200).style('opacity', function(d) {
- return d.hidden ? '0.3' : '1';
+ links.transition().duration(200).style('opacity', function (d) {
+ return d.hidden ? '0.3' : '1';
});
};
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-define(['app/ovsdb/ovsdb.module', 'app/ovsdb/OvsCore', 'underscore', 'app/ovsdb/ovsdb.constant'], function(ovsdb, OvsCore, _) {
+define(['app/ovsdb/ovsdb.module', 'app/ovsdb/OvsCore', 'underscore', 'app/ovsdb/ovsdb.constant'], function (ovsdb, OvsCore, _) {
'use strict';
- ovsdb.register.factory('OvsdbRestangular', ['Restangular', 'ENV', function(Restangular, ENV) {
- return Restangular.withConfig(function(RestangularConfig) {
+ ovsdb.register.factory('OvsdbRestangular', ['Restangular', 'ENV', function (Restangular, ENV) {
+ return Restangular.withConfig(function (RestangularConfig) {
RestangularConfig.setBaseUrl(ENV.getBaseURL("MD_SAL"));
});
}]);
// nbv2 support depricated in dlux
- ovsdb.register.factory('NeutronRestangular', ['Restangular', function(Restangular) {
- return Restangular.withConfig(function(RestangularConfig) {
+ ovsdb.register.factory('NeutronRestangular', ['Restangular', function (Restangular) {
+ return Restangular.withConfig(function (RestangularConfig) {
RestangularConfig.setBaseUrl('http://localhost:8080/controller/nb/v2/neutron');
});
}]);
- ovsdb.register.factory('CacheFactory', function($q) {
+ ovsdb.register.factory('CacheFactory', function ($q) {
var svc = {},
ovsCache = {};
/*BUG : Using the persistant cache make the physical
* algorithm. The current behavior is to use the cache
* only the pile up the datas.
*/
- svc.obtainDataFromCache = function(key, fn, ctx) {
+ svc.obtainDataFromCache = function (key, fn, ctx) {
var cacheDefer = $q.defer();
if (angular.isUndefined(ovsCache[key])) {
- fn.call(ctx, function(data) {
- ovsCache[key] = {
- obj : data,
- timestamp : Date.now() + 2000//300000 // 5 mintues
- };
- cacheDefer.resolve(data);
+ fn.call(ctx, function (data) {
+ ovsCache[key] = {
+ obj: data,
+ timestamp: Date.now() + 2000 //300000 // 5 mintues
+ };
+ cacheDefer.resolve(data);
});
} else {
var cacheObj = ovsCache[key];
- if (cacheObj.timestamp < Date.now() || _.isEmpty(cacheObj.obj)) {
- fn.call(ctx, function(data) {
- ovsCache[key] = {
- obj : data,
- timestamp : Date.now() + 2000//300000 // 5 mintues
- };
- cacheDefer.resolve(data);
+ if (cacheObj.timestamp < Date.now() || _.isEmpty(cacheObj.obj)) {
+ fn.call(ctx, function (data) {
+ ovsCache[key] = {
+ obj: data,
+ timestamp: Date.now() + 2000 //300000 // 5 mintues
+ };
+ cacheDefer.resolve(data);
});
} else {
cacheDefer.resolve(cacheObj.obj);
return cacheDefer.promise;
};
- svc.getCacheObj = function(key) {
+ svc.getCacheObj = function (key) {
if (angular.isUndefined(ovsCache[key])) {
ovsCache[key] = {};
}
return svc;
});
- var TopologySvc = function(OvsdbRestangular, nodeIdentifier, ovsNodeKeys, bridgeNodeKeys, tpKeys, flowInfoKeys, linkIdentifier, $q, $http, CacheFactory) {
+ var TopologySvc = function (OvsdbRestangular, nodeIdentifier, ovsNodeKeys, bridgeNodeKeys, tpKeys, flowInfoKeys, linkIdentifier, OVSConstant, $q, $http, CacheFactory) {
var svc = {
- base: function(type) {
+ base: function (type) {
return OvsdbRestangular.one('restconf').one(type);
}
};
}
if (_.isArray(otherInfo)) {
- _.each(otherInfo, function(value) {
+ _.each(otherInfo, function (value) {
if (value[ovsNodeKeys.OTHER_CONFIG_KEY] === 'local_ip') {
otherLocalIp = value[ovsNodeKeys.OTHER_CONFIG_VALUE];
}
tp = node[bridgeNodeKeys.TP],
controllerEntries = node[bridgeNodeKeys.CONTROLLER_ENTRY];
- _.each(controllerEntries, function(value) {
+ _.each(controllerEntries, function (value) {
controllerTarget = value[bridgeNodeKeys.TARGET];
controllerEntries = value[bridgeNodeKeys.IS_CONNECTED];
return false; // break the anonymus function
bridgeNode = new OvsCore.BridgeNode(node[bridgeNodeKeys.NODE_ID], node[bridgeNodeKeys.DATA_PATH], node[bridgeNodeKeys.BRIDGE_NAME], controllerTarget, controllerConnected);
- _.each(tp, function(value) {
+ _.each(tp, function (value) {
var tp = parseBridgeTP(value);
if (tp.ofPort == '65534' && (tp.name === 'br-ex' || tp.name === 'br-int')) {
function parseBridgeTP(tp) {
var mac = '',
ifaceId = '',
- extInfo = tp['ovsdb:port-external-ids'] || tp['ovsdb:interface-external-ids'];
+ extInfo = tp['ovsdb:port-external-ids'] || tp['ovsdb:interface-external-ids'],
+ type = tp[tpKeys.INTERFACE_TYPE];
- _.each(extInfo, function(ext) {
+ _.each(extInfo, function (ext) {
if (ext[tpKeys.EXTERNAL_KEY_ID] === tpKeys.ATTACHED_MAC) {
mac = ext[tpKeys.EXTERNAL_KEY_VALUE];
}
ifaceId = ext[tpKeys.EXTERNAL_KEY_VALUE] || '';
}
});
+ if (type === OVSConstant.TP_TYPE.VXLAN) {
+ var localIp = null,
+ remoteIp = null;
+ _.each(tp['ovsdb:options'], function (option) {
+ switch (option.option) {
+ case 'local_ip':
+ localIp = option.value;
+ break;
+ case 'remote_ip':
+ remoteIp = option.value;
+ break;
+ }
+ });
+ return new OvsCore.Tunnel(tp[tpKeys.NAME], tp[tpKeys.OF_PORT], type, mac, ifaceId, localIp, remoteIp);
+ }
+ return new OvsCore.TerminationPoint(tp[tpKeys.NAME], tp[tpKeys.OF_PORT], type, mac, ifaceId);
- return new OvsCore.TerminationPoint(tp[tpKeys.NAME], tp[tpKeys.OF_PORT], tp[tpKeys.INTERFACE_TYPE], mac, ifaceId);
}
function fetchTopology(cb) {
var netTopoDefer = this.base('operational').one('network-topology:network-topology').getList();
// be sure all data are loaded
- $q.all([invNodeDefer, netTopoDefer]).then(function(values) {
+ $q.all([invNodeDefer, netTopoDefer]).then(function (values) {
var invNode = values[0],
netTopo = values[1],
index_hash = [],
nodes = invNode.nodes.node,
topo = new OvsCore.Topology();
- _.each(topologies, function(topology, topo_index) {
+ _.each(topologies, function (topology, topo_index) {
if (!topology.hasOwnProperty('topology-id')) {
throw new Error('Invalide JSON format, no topology-id for the topology [' + topo_index + ']');
}
// if there no node it will be an empty array so noop
- (topology.node || []).forEach(function(node) {
+ (topology.node || []).forEach(function (node) {
if (!node[nodeIdentifier.ID]) {
throw new Error('Unexpected node : undefined ' + nodeIdentifier.ID + ' key');
}
});
// if there no link it will be an empty array so noop
- (topology.link || []).forEach(function(link) {
+ (topology.link || []).forEach(function (link) {
var source = link[linkIdentifier.SRC]['source-node'],
dest = link[linkIdentifier.DEST]['dest-node'];
});
- _.each(nodes, function(node, index) {
+ _.each(nodes, function (node, index) {
if (!node.id) {
return;
}
var bridgeId = node.id;
- var bridgeNode = _.filter(topo.bridgeNodes, function(bridgeNode) {
+ var bridgeNode = _.filter(topo.bridgeNodes, function (bridgeNode) {
return bridgeNode.getFLowName() === bridgeId;
})[0];
bridgeNode.flowInfo.manufacturer = node[flowInfoKeys.MANUFACTURER];
bridgeNode.flowInfo.ip = node[flowInfoKeys.IP];
- _.each(node[flowInfoKeys.TABLE], function(entry) {
+ _.each(node[flowInfoKeys.TABLE], function (entry) {
if (!_.isUndefined(entry.id)) {
- _.each(entry.flow, function(flow) {
- bridgeNode.addFlowTableInfo({ key: flow.table_id, value: flow.id});
+ _.each(entry.flow, function (flow) {
+ bridgeNode.addFlowTableInfo({
+ key: flow.table_id,
+ value: flow.id
+ });
});
}
});
});
// show relation between ovsNode and switch with a link
- _.each(topo.ovsdbNodes, function(node, index) {
- var bridges = _.filter(topo.bridgeNodes, function(bnode) {
+ _.each(topo.ovsdbNodes, function (node, index) {
+ var bridges = _.filter(topo.bridgeNodes, function (bnode) {
return bnode.nodeId.indexOf(node.nodeId) > -1;
});
- _.each(bridges, function(bridge) {
+ _.each(bridges, function (bridge) {
var size = _.size(topo.links),
link = new OvsCore.BridgeOvsLink(++size, node.nodeId, bridge.nodeId);
topo.registerLink(link);
function findVxlan(bridgeNode) {
var tunnels = [];
- _.each(bridgeNode, function(node) {
- var ovsdbNode = _.find(topo.ovsdbNodes, function(oNode) {
+ _.each(bridgeNode, function (node) {
+ var ovsdbNode = _.find(topo.ovsdbNodes, function (oNode) {
return node.nodeId.indexOf(oNode.nodeId) > -1;
});
if (!ovsdbNode) {
return false;
}
- _.each(node.tPs, function(tp, index) {
- if (tp.name.indexOf('vxlan-') > -1) {
+ _.each(node.tPs, function (tp, index) {
+ if (tp instanceof OvsCore.Tunnel) {
tunnels.push({
- port : tp,
- bridge : node,
- ovsIp : ovsdbNode.otherLocalIp || ovsdbNode.inetMgr
+ port: tp,
+ bridge: node
});
}
});
// extract all tunnel paired with their bridge
var tunnels = findVxlan(topo.bridgeNodes);
// loop over all pairs
- _.each(tunnels, function(tunnel, index) {
- var currIp = tunnel.ovsIp,
- destIp = tunnel.port.name.replace('vxlan-', ''),
- linkedBridge = _.find(tunnels.slice(index), function(t) {
- var vxlanIp = t.port.name.replace('vxlan-', '');
- return vxlanIp === currIp;
+ for (var index = 0; index < tunnels.length; ++index) {
+ var tunnel = tunnels[index],
+ currIp = tunnel.port.localIp,
+ destIp = tunnel.port.remoteIp,
+ pairIndex = 0,
+ linkedBridge = _.find(tunnels, function (t, i) {
+ pairIndex = i;
+ return t.port.remoteIp === currIp && t.port.localIp == destIp;
});
- if (linkedBridge) {
- topo.registerLink(new OvsCore.TunnelLink(tunnel.port.name + linkedBridge.port.name, tunnel.bridge.nodeId, linkedBridge.bridge.nodeId));
- }
- });
+ if (linkedBridge) {
+ tunnels.splice(pairIndex, 1);
+ topo.registerLink(new OvsCore.TunnelLink(tunnel.port.name + linkedBridge.port.name, tunnel.bridge.nodeId, linkedBridge.bridge.nodeId));
+ }
+ }
topo.updateLink();
cb(topo);
},
- function(err) {
+ function (err) {
throw err;
}
);
}
- svc.getTopologies = function() {
+ svc.getTopologies = function () {
return CacheFactory.obtainDataFromCache('topologies', fetchTopology, this);
};
return svc;
};
- TopologySvc.$inject = ['OvsdbRestangular', 'nodeIdentifier', 'ovsNodeKeys', 'bridgeNodeKeys', 'tpKeys', 'flowInfoKeys', 'linkIdentifier', '$q', '$http', 'CacheFactory'];
+ TopologySvc.$inject = ['OvsdbRestangular', 'nodeIdentifier', 'ovsNodeKeys', 'bridgeNodeKeys', 'tpKeys', 'flowInfoKeys', 'linkIdentifier', 'OVSConstant', '$q', '$http', 'CacheFactory'];
- var NeutronSvc = function(NeutronRestangular, CacheFactory, $q, $http) {
+ var NeutronSvc = function (NeutronRestangular, CacheFactory, $q, $http) {
var svc = {
- base: function(type) {
- return NeutronRestangular.one(type);
- }
- },
- tenant_hash = {};
+ base: function (type) {
+ return NeutronRestangular.one(type);
+ }
+ },
+ tenant_hash = {};
function fetchSubNetworks(cb) {
var subnetskDefer = svc.base('subnets').getList();
- subnetskDefer.then(function(data) {
+ subnetskDefer.then(function (data) {
var subnets = data,
subnetHash = {};
throw new Error('Invalid format from neutron subnets');
}
- _.each(subnets.subnets, function(subnet) {
- if (!subnetHash[subnet.network_id]) {
- subnetHash[subnet.network_id] = [];
- }
- tenant_hash[subnet.tenant_id] = {};
- subnetHash[subnet.network_id].push(new OvsCore.Neutron.SubNet(
- subnet.id,
- subnet.network_id,
- subnet.name,
- subnet.ip_version,
- subnet.cidr,
- subnet.gateway_ip,
- subnet.tenant_id
- ));
+ _.each(subnets.subnets, function (subnet) {
+ if (!subnetHash[subnet.network_id]) {
+ subnetHash[subnet.network_id] = [];
+ }
+ tenant_hash[subnet.tenant_id] = {};
+ subnetHash[subnet.network_id].push(new OvsCore.Neutron.SubNet(
+ subnet.id,
+ subnet.network_id,
+ subnet.name,
+ subnet.ip_version,
+ subnet.cidr,
+ subnet.gateway_ip,
+ subnet.tenant_id
+ ));
});
cb(subnetHash);
});
var networkDefer = svc.base('networks').getList();
var subnetskDefer = svc.getSubNets();
- $q.all([subnetskDefer, networkDefer]).then(function(datas) {
+ $q.all([subnetskDefer, networkDefer]).then(function (datas) {
var subnetsHash = datas[0],
networks = datas[1],
networkArray = [];
throw new Error('Invalid format from neutron networks');
}
- _.each(networks.networks, function(network) {
+ _.each(networks.networks, function (network) {
var net = new OvsCore.Neutron.Network(
network.id,
network.name,
net.addSubNets(subnetsHash[net.id]);
networkArray.push(net);
});
- cb(networkArray);
+ cb(networkArray);
});
}
function fetchRouters(cb) {
var routerDefer = svc.base('routers').getList();
- routerDefer.then(function(data) {
+ routerDefer.then(function (data) {
var routers = data.routers,
routerArray = [];
if (!routers) {
throw new Error('Invalid format from neutron routers');
}
- _.each(routers, function(router) {
- var id = router.id,
+ _.each(routers, function (router) {
+ var id = router.id,
name = router.name,
status = router.status,
tenantId = router.tenant_id,
extGateWayInfo = router.external_gateway_info;
- tenant_hash[tenantId] = {};
- routerArray.push(new OvsCore.Neutron.Router(
- id, name, status, tenantId, extGateWayInfo
- ));
+ tenant_hash[tenantId] = {};
+ routerArray.push(new OvsCore.Neutron.Router(
+ id, name, status, tenantId, extGateWayInfo
+ ));
});
cb(routerArray);
});
function fetchPorts(cb) {
var portDefer = svc.base('ports').getList();
- portDefer.then(function(data){
+ portDefer.then(function (data) {
var ports = data.ports,
portArray = [];
if (!ports) {
throw new Error('Invalid format from neutron ports');
}
- _.each(ports, function(port) {
+ _.each(ports, function (port) {
tenant_hash[port.tenant_id] = {};
portArray.push(new OvsCore.Neutron.Port(
port.id,
function fetchFloatingIps(cb) {
var floatingIpDefer = svc.base('floatingips').getList();
- floatingIpDefer.then(function(data) {
+ floatingIpDefer.then(function (data) {
var floatingIps = data.floatingips,
floatingIpArray = [];
throw new Error('Invalid format from neutron floatingIps');
}
- _.each(floatingIps, function(fIp) {
+ _.each(floatingIps, function (fIp) {
tenant_hash[fIp.tenant_id] = {};
floatingIpArray.push(new OvsCore.Neutron.FloatingIp(
fIp.id,
});
}
- svc.getNetworks = function() {
- return CacheFactory.obtainDataFromCache('networks', fetchNetworks, this);
+ svc.getNetworks = function () {
+ return CacheFactory.obtainDataFromCache('networks', fetchNetworks, this);
};
- svc.getSubNets = function() {
+ svc.getSubNets = function () {
return CacheFactory.obtainDataFromCache('subnet', fetchSubNetworks, this);
};
- svc.getPorts = function() {
+ svc.getPorts = function () {
return CacheFactory.obtainDataFromCache('ports', fetchPorts, this);
};
- svc.getRouters = function() {
+ svc.getRouters = function () {
return CacheFactory.obtainDataFromCache('routers', fetchRouters, this);
};
- svc.getFloatingIps = function() {
+ svc.getFloatingIps = function () {
return CacheFactory.obtainDataFromCache('floatingips', fetchFloatingIps, this);
};
- svc.getAllTenants = function() {
+ svc.getAllTenants = function () {
return Object.keys(tenant_hash);
};
};
NeutronSvc.$inject = ['NeutronRestangular', 'CacheFactory', '$q', '$http'];
- var OvsUtil = function(NeutronSvc, TopologySvc, CacheFactory, $q) {
+ var OvsUtil = function (NeutronSvc, TopologySvc, CacheFactory, $q) {
var svc = {};
function findOvsdbNodeForBridge(ovsdbNodes, bridge) {
- return _.find(ovsdbNodes, function(node) {
+ return _.find(ovsdbNodes, function (node) {
return bridge.nodeId.indexOf(node.nodeId) > -1;
});
}
$q.all([networksDefer, routersDefer, portsDefer, floatingDefer, netTopoDefer]).then(function (datas) {
var networks = datas[0],
- routers = datas[1],
- ports = datas[2],
- floatingIps = datas[3],
- topo = datas[4];
+ routers = datas[1],
+ ports = datas[2],
+ floatingIps = datas[3],
+ topo = datas[4];
// match ports with elements
- _.each(ports, function(port) {
- port.topoInfo = [];
- // corelate port.topoInfo data with network topology termination point
- _.each(topo.bridgeNodes, function(bridge) {
- _.each(bridge.tPs, function(tp) {
- if (tp.ifaceId === port.id) {
- port.topoInfo.push({
- name : tp.name,
- ofPort : tp.ofPort,
- mac : bridge.dpIp,
- bridge : bridge,
- ovsNode : findOvsdbNodeForBridge(topo.ovsdbNodes, bridge)
- });
- }
- });
- });
-
- switch(port.deviceOwner) {
- case 'network:router_gateway':
- case 'network:router_interface':
- var router = _.find(routers, function(r) { return r.id === port.deviceId; });
+ _.each(ports, function (port) {
+ port.topoInfo = [];
+ // corelate port.topoInfo data with network topology termination point
+ _.each(topo.bridgeNodes, function (bridge) {
+ _.each(bridge.tPs, function (tp) {
+ if (tp.ifaceId === port.id) {
+ port.topoInfo.push({
+ name: tp.name,
+ ofPort: tp.ofPort,
+ mac: bridge.dpIp,
+ bridge: bridge,
+ ovsNode: findOvsdbNodeForBridge(topo.ovsdbNodes, bridge)
+ });
+ }
+ });
+ });
+
+ switch (port.deviceOwner) {
+ case 'network:router_gateway':
+ case 'network:router_interface':
+ var router = _.find(routers, function (r) {
+ return r.id === port.deviceId;
+ });
if (router) {
router.interfaces.push({
id: port.id,
- networkId : port.networkId,
- ip : port.fixed_ips[0],
- mac : port.mac,
+ networkId: port.networkId,
+ ip: port.fixed_ips[0],
+ mac: port.mac,
type: port.deviceOwner.replace('network:', ''),
- tenantId : port.tenantId,
+ tenantId: port.tenantId,
topoInfo: port.topoInfo
});
}
case 'compute:None':
case 'compute:nova':
case 'network:dhcp':
- var network = _.find(networks, function(n) { return n.id === port.networkId;}),
+ var network = _.find(networks, function (n) {
+ return n.id === port.networkId;
+ }),
inst = null;
if (network) {
- inst = new OvsCore.Neutron.Instance(port.id, port.networkId,
+ inst = new OvsCore.Neutron.Instance(port.id, port.networkId,
port.name, port.fixed_ips[0].ip_address, port.mac,
- port.deviceOwner, port.tenantId, port.topoInfo );
+ port.deviceOwner, port.tenantId, port.topoInfo);
inst.extractFloatingIps(floatingIps);
network.instances.push(inst);
}
break;
- }
+ }
- });
+ });
- // find all routers for a specific network
- _.each(networks, function(network) {
- network.routers = _.filter(routers, function(router) {
- return network.id === router.externalGateway.network_id;
- });
+ // find all routers for a specific network
+ _.each(networks, function (network) {
+ network.routers = _.filter(routers, function (router) {
+ return network.id === router.externalGateway.network_id;
+ });
- // order instance by ip
- network.instances.sort(function(a, b) {
- var ipA = a.ip.slice(a.ip.lastIndexOf('.') + 1),
- ipB = b.ip.slice(b.ip.lastIndexOf('.') + 1);
- return ipA - ipB;
- });
- });
+ // order instance by ip
+ network.instances.sort(function (a, b) {
+ var ipA = a.ip.slice(a.ip.lastIndexOf('.') + 1),
+ ipB = b.ip.slice(b.ip.lastIndexOf('.') + 1);
+ return ipA - ipB;
+ });
+ });
- cb(networks);
+ cb(networks);
});
}
- svc.getLogicalTopology = function() {
+ svc.getLogicalTopology = function () {
return CacheFactory.obtainDataFromCache('logicalTopology', pileUpTopologyData, this);
};
- svc.extractLogicalByTenant = function(tenantId, subSet) {
+ svc.extractLogicalByTenant = function (tenantId, subSet) {
var lTopoDefer = svc.getLogicalTopology(),
resultDefer = $q.defer();
- lTopoDefer.then(function() {
+ lTopoDefer.then(function () {
var ports = CacheFactory.getCacheObj('ports').obj,
- filteredPorts = _.filter(ports, function(p) {
+ filteredPorts = _.filter(ports, function (p) {
return p.tenantId === tenantId;
});
if (!_.isEmpty(filteredPorts)) {
var bridgeHash = {};
- _.each(filteredPorts, function(p) {
+ _.each(filteredPorts, function (p) {
if (!_.isEmpty(p.topoInfo) && !bridgeHash[p.topoInfo[0].bridge.nodeId]) {
bridgeHash[p.topoInfo[0].bridge.nodeId] = {};
}
});
var ovsdbHash = {};
- _.each(filteredPorts, function(p) {
+ _.each(filteredPorts, function (p) {
if (!_.isEmpty(p.topoInfo) && !ovsdbHash[p.topoInfo[0].ovsNode.nodeId]) {
ovsdbHash[p.topoInfo[0].ovsNode.nodeId] = {};
}
return resultDefer.promise;
};
- svc.extractLogicalBySubnet = function(subnets, subSet) {
+ svc.extractLogicalBySubnet = function (subnets, subSet) {
var lTopoDefer = svc.getLogicalTopology(),
resultDefer = $q.defer();
- lTopoDefer.then(function() {
+ lTopoDefer.then(function () {
var ports = CacheFactory.getCacheObj('ports').obj,
networks = CacheFactory.getCacheObj('networks').obj;
- var filteredPorts = _.filter(ports, function(p) {
- var net = _.find(networks, function(d) {
+ var filteredPorts = _.filter(ports, function (p) {
+ var net = _.find(networks, function (d) {
return d.id === p.networkId;
});
});
if (!_.isEmpty(filteredPorts)) {
var bridgeHash = {};
- _.each(filteredPorts, function(p) {
+ _.each(filteredPorts, function (p) {
if (!_.isEmpty(p.topoInfo) && !bridgeHash[p.topoInfo[0].bridge.nodeId]) {
bridgeHash[p.topoInfo[0].bridge.nodeId] = {};
}
});
var ovsdbHash = {};
- _.each(filteredPorts, function(p) {
+ _.each(filteredPorts, function (p) {
if (!_.isEmpty(p.topoInfo) && !ovsdbHash[p.topoInfo[0].ovsNode.nodeId]) {
ovsdbHash[p.topoInfo[0].ovsNode.nodeId] = {};
}
* and is available at http://www.eclipse.org/legal/epl-v10.html\r
-->\r
<div id="ovsdb_contain">\r
-<!--\r
+ <!--\r
<div class="row">\r
<div class="col-md-2 form-inline">\r
<label class="switch-light well">\r
</div>\r
</div>\r
-->\r
-<div class="row">\r
- <div class="col-md-12">\r
- <div id="tabs" >\r
- <ul class="nav nav-tabs tabsHeader" style="margin-bottom:15px;">\r
- <li><a href="#logical_view">Logical View</a></li>\r
- <li><a href="#2d_view">2D View</a></li>\r
- <li><a href="#3d_view">3D View</a></li>\r
- </ul>\r
- <div id="logical_view" style="background-color:white; position:relative;">\r
- <div id="l_graph" style="position:relative; height:580px;" logical-graph ></div>\r
+ <div class="row">\r
+ <div class="col-md-12">\r
+ <div id="tabs">\r
+ <ul class="nav nav-tabs tabsHeader" style="margin-bottom:15px;">\r
+ <li><a href="#logical_view">Logical View</a></li>\r
+ <li><a href="#2d_view">2D View</a></li>\r
+ </ul>\r
+ <div id="logical_view" style="background-color:white; position:relative;">\r
+ <div id="l_graph" style="position:relative; height:580px;" logical-graph></div>\r
\r
- <div id="lDialog" class="ovsDialog arrow-left">\r
- <div style="height:10px;">\r
- <i data-ng-click="hideLogicalDialog()" class="window-icon icon-remove"></i>\r
- </div>\r
- <div class="window_content">\r
- <ul class="nav nav-tabs tabsHeader">\r
- <li ng-repeat="tab in lDialogData.tabs track by $index" >\r
- <a href="#lDialogTab_{{$index}}" class="active">{{tab}}</a>\r
- </li>\r
- </ul>\r
- <div ng-repeat="tabContaint in lDialogData.containts track by $index" id="lDialogTab_{{$index}}">\r
- <table ng-if="!tabContaint.hasHeader" class="table table-bordered" style="margin-bottom:0;">\r
- <tr ng-repeat="info in tabContaint.datas track by $index">\r
- <td > {{info.key}} </td> <td> {{ info.value }} </td>\r
- </tr>\r
- </table>\r
- <table ng-if="tabContaint.hasHeader" class="table table-bordered" style="margin-bottom:0;">\r
- <tr>\r
- <th ng-repeat=" h in tabContaint.header track by $index">{{h}}</th>\r
- </tr>\r
- <tr ng-repeat="item in tabContaint.datas track by $index">\r
- <td ng-repeat="value in item track by $index"> {{ value }} </td>\r
- </tr>\r
- </table>\r
+ <div id="lDialog" class="ovsDialog arrow-left">\r
+ <div style="height:10px;">\r
+ <i data-ng-click="hideLogicalDialog()" class="window-icon icon-remove"></i>\r
+ </div>\r
+ <div class="window_content">\r
+ <ul class="nav nav-tabs tabsHeader">\r
+ <li ng-repeat="tab in lDialogData.tabs track by $index">\r
+ <a href="#lDialogTab_{{$index}}" class="active">{{tab}}</a>\r
+ </li>\r
+ </ul>\r
+ <div ng-repeat="tabContaint in lDialogData.containts track by $index" id="lDialogTab_{{$index}}">\r
+ <table ng-if="!tabContaint.hasHeader" class="table table-bordered" style="margin-bottom:0;">\r
+ <tr ng-repeat="info in tabContaint.datas track by $index">\r
+ <td> {{info.key}} </td>\r
+ <td> {{ info.value }} </td>\r
+ </tr>\r
+ </table>\r
+ <table ng-if="tabContaint.hasHeader" class="table table-bordered" style="margin-bottom:0;">\r
+ <tr>\r
+ <th ng-repeat=" h in tabContaint.header track by $index">{{h}}</th>\r
+ </tr>\r
+ <tr ng-repeat="item in tabContaint.datas track by $index">\r
+ <td ng-repeat="value in item track by $index"> {{ value }} </td>\r
+ </tr>\r
+ </table>\r
+ </div>\r
</div>\r
</div>\r
- </div>\r
\r
- </div>\r
- <div id="2d_view">\r
- <div class="row">\r
- <div class="col-md-4 col-md-offset-1 form-inline">\r
- <span>Tenant</span>\r
- <select id="tenantSelect" ng-model="selectedTenant" ng-change="fiterByTenant()" ng-options="tenant.name for tenant in tenants track by tenant.id">\r
- <option value="">---All---</option>\r
- </select>\r
- </div>\r
- <div class="col-md-4 form-inline">\r
- <span>Subnet</span>\r
- <select id="tagPicker" multiple="multiple" ng-model="selectedSubnet" ng-change="filterBySubnet()" ng-options="subnet.name for subnet in subnets track by subnet.id">\r
- </select>\r
- </div>\r
</div>\r
- <div id="nv_graph" style="position:relative; height:580px;" physical-graph></div>\r
- <div id="pDialog" class="ovsDialog arrow-left">\r
+ <div id="2d_view">\r
+ <div class="row">\r
+ <div class="col-md-4 col-md-offset-1 form-inline">\r
+ <span>Tenant</span>\r
+ <select id="tenantSelect" ng-model="selectedTenant" ng-change="fiterByTenant()" ng-options="tenant.name for tenant in tenants track by tenant.id">\r
+ <option value="">---All---</option>\r
+ </select>\r
+ </div>\r
+ <div class="col-md-4 form-inline">\r
+ <span>Subnet</span>\r
+ <select id="tagPicker" multiple="multiple" ng-model="selectedSubnet" ng-change="filterBySubnet()" ng-options="subnet.name for subnet in subnets track by subnet.id">\r
+ </select>\r
+ </div>\r
+ </div>\r
+ <div id="nv_graph" style="position:relative; height:580px;" physical-graph></div>\r
+ <div id="pDialog" class="ovsDialog arrow-left">\r
<div style="height:10px">\r
<i data-ng-click="hidePhysicalDialog()" class="window-icon icon-remove"></i>\r
</div>\r
- <div class="window_content">\r
- <ul class="nav nav-tabs tabsHeader">\r
- <li ng-repeat="tab in pDialogData.tabs track by $index" >\r
- <a href="#pDialogTab_{{$index}}" class="active">{{tab}}</a>\r
- </li>\r
- </ul>\r
- <div ng-repeat="tabContaint in pDialogData.containts track by $index" id="pDialogTab_{{$index}}">\r
- <table ng-if="!tabContaint.hasHeader" class="table table-bordered" style="margin-bottom:0;">\r
- <tr ng-repeat="info in tabContaint.datas track by $index">\r
- <td > {{info.key}} </td> <td> {{ info.value }} </td>\r
- </tr>\r
- </table>\r
- <table ng-if="tabContaint.hasHeader" class="table table-bordered" style="margin-bottom:0;">\r
- <tr>\r
- <th ng-repeat=" h in tabContaint.header track by $index">{{h}}</th>\r
- </tr>\r
- <tr ng-repeat="item in tabContaint.datas track by $index">\r
- <td ng-repeat="value in item track by $index"> {{ value }} </td>\r
- </tr>\r
- </table>\r
+ <div class="window_content">\r
+ <ul class="nav nav-tabs tabsHeader">\r
+ <li ng-repeat="tab in pDialogData.tabs track by $index">\r
+ <a href="#pDialogTab_{{$index}}" class="active">{{tab}}</a>\r
+ </li>\r
+ </ul>\r
+ <div ng-repeat="tabContaint in pDialogData.containts track by $index" id="pDialogTab_{{$index}}">\r
+ <table ng-if="!tabContaint.hasHeader" class="table table-bordered" style="margin-bottom:0;">\r
+ <tr ng-repeat="info in tabContaint.datas track by $index">\r
+ <td> {{info.key}} </td>\r
+ <td> {{ info.value }} </td>\r
+ </tr>\r
+ </table>\r
+ <table ng-if="tabContaint.hasHeader" class="table table-bordered" style="margin-bottom:0;">\r
+ <tr>\r
+ <th ng-repeat=" h in tabContaint.header track by $index">{{h}}</th>\r
+ </tr>\r
+ <tr ng-repeat="item in tabContaint.datas track by $index">\r
+ <td ng-repeat="value in item track by $index"> {{ value }} </td>\r
+ </tr>\r
+ </table>\r
+ </div>\r
</div>\r
</div>\r
</div>\r
-\r
</div>\r
- <!-- <div id="3d_view">\r
- </div> -->\r
- </div><!-- tab -->\r
-</div>\r
+ <!-- tab -->\r
+ </div>\r
"requests": [
{
"collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n \"access-lists\": {\n \"access-list\": [\n {\n \"acl-name\": \"http-acl\",\n \"access-list-entries\": {\n \"access-list-entry\": [\n {\n \"rule-name\": \"http-rule\",\n \"matches\": {\n \"destination-port-range\": {\n \"lower-port\": \"80\",\n \"upper-port\": \"80\"\n }\n },\n \"actions\": {\n \"permit\": {}\n }\n }\n ]\n }\n }\n ]\n }\n}",
+ "data": "{\n \"access-lists\": {\n \"acl\": [\n {\n \"acl-name\": \"http-acl\",\n \"access-list-entries\": {\n \"ace\": [\n {\n \"rule-name\": \"http-rule\",\n \"matches\": {\n \"destination-port-range\": {\n \"lower-port\": \"80\",\n \"upper-port\": \"80\"\n }\n },\n \"actions\": {\n \"netvirt-sfc-acl:redirect-sfc\": \"acl\"\n }\n }\n ]\n }\n }\n ]\n }\n}",
"dataMode": "raw",
"description": "",
- "headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
- "id": "37a68007-fc51-b406-43fe-dcaba62e3879",
- "method": "GET",
- "name": "Acl",
- "responses": [],
+ "headers": "Content-Type: application/json\n",
+ "id": "19b44f74-e2ea-9267-50af-ad79b6309859",
+ "method": "PUT",
+ "name": "ietf-acl redirect-sfc",
+ "time": 1445298337983,
+ "timestamp": 0,
+ "url": "http://localhost:8181/restconf/config/ietf-access-control-list:access-lists",
+ "version": 2
+ },
+ {
+ "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
+ "data": "{\n \"service-function-forwarders\": {\n \"service-function-forwarder\": [\n {\n \"name\": \"SFF1\",\n \"service-node\": \"OVSDB2\",\n \"service-function-forwarder-ovs:ovs-bridge\": {\n \"bridge-name\": \"sw2\"\n },\n \"service-function-dictionary\": [\n {\n \"name\": \"firewall-72\",\n \"type\": \"service-function-type:firewall\",\n \"sff-sf-data-plane-locator\": {\n \"port\": 6633,\n \"ip\": \"192.168.50.71\",\n \"transport\": \"service-locator:vxlan-gpe\"\n }\n }\n ],\n \"sff-data-plane-locator\": [\n {\n \"name\": \"sfc-tun2\",\n \"data-plane-locator\": {\n \"transport\": \"service-locator:vxlan-gpe\",\n \"port\": 6633,\n \"ip\": \"192.168.50.71\"\n },\n \"service-function-forwarder-ovs:ovs-options\": {\n \"remote-ip\": \"flow\",\n \"dst-port\": \"6633\",\n \"key\": \"flow\",\n \"nsp\": \"flow\",\n \"nsi\": \"flow\",\n \"nshc1\": \"flow\",\n \"nshc2\": \"flow\",\n \"nshc3\": \"flow\",\n \"nshc4\": \"flow\"\n }\n }\n ]\n },\n {\n \"name\": \"SFF2\",\n \"service-node\": \"OVSDB2\",\n \"service-function-forwarder-ovs:ovs-bridge\": {\n \"bridge-name\": \"sw4\"\n },\n \"service-function-dictionary\": [\n {\n \"name\": \"dpi-74\",\n \"type\": \"service-function-type:dpi\",\n \"sff-sf-data-plane-locator\": {\n \"port\": 6633,\n \"ip\": \"192.168.50.73\",\n \"transport\": \"service-locator:vxlan-gpe\"\n }\n }\n ],\n \"sff-data-plane-locator\": [\n {\n \"name\": \"sfc-tun4\",\n \"data-plane-locator\": {\n \"transport\": \"service-locator:vxlan-gpe\",\n \"port\": 6633,\n \"ip\": \"192.168.50.73\"\n },\n \"service-function-forwarder-ovs:ovs-options\": {\n \"remote-ip\": \"flow\",\n \"dst-port\": \"6633\",\n \"key\": \"flow\",\n \"nsp\": \"flow\",\n \"nsi\": \"flow\",\n \"nshc1\": \"flow\",\n \"nshc2\": \"flow\",\n \"nshc3\": \"flow\",\n \"nshc4\": \"flow\"\n }\n }\n ]\n }\n ]\n }\n}",
+ "dataMode": "raw",
+ "description": "",
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
+ "id": "1b067065-f0d5-d871-28cf-5e7e195eb463",
+ "method": "PUT",
+ "name": "service-function-forwarders",
+ "time": 1445302610648,
+ "timestamp": 0,
+ "url": "http://localhost:8181/restconf/config/service-function-forwarder:service-function-forwarders",
+ "version": 2
+ },
+ {
+ "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
+ "data": "{\n \"access-lists\": {\n \"acl\": [\n {\n \"acl-name\": \"http-acl\",\n \"access-list-entries\": {\n \"ace\": [\n {\n \"rule-name\": \"http-rule\",\n \"matches\": {\n \"destination-port-range\": {\n \"lower-port\": \"80\",\n \"upper-port\": \"80\"\n }\n },\n \"actions\": {\n \"permit\": \"true\"\n\n }\n }\n ]\n }\n }\n ]\n }\n}",
+ "dataMode": "raw",
+ "description": "",
+ "headers": "Content-Type: application/json\n",
+ "id": "62e3b4d9-2672-e2bd-25c9-70bfb6771026",
+ "method": "PUT",
+ "name": "ietf-acl",
+ "time": 1445298397905,
"timestamp": 0,
- "url": "http://localhost:8181/restconf/config/ietf-acl:access-lists",
+ "url": "http://localhost:8181/restconf/config/ietf-access-control-list:access-lists",
"version": 2
},
{
},
{
"collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n\t\"sfc\": {\n \"name\": \"sfc1\"\n }\n}",
+ "data": "{\n \"access-lists\": {\n \"acl\": [\n {\n \"acl-name\": \"http-acl\",\n \"access-list-entries\": {\n \"ace\": [\n {\n \"rule-name\": \"http-rule\",\n \"matches\": {\n \"destination-port-range\": {\n \"lower-port\": \"80\",\n \"upper-port\": \"80\"\n }\n },\n \"actions\": {\n \"permit\": {}\n }\n }\n ]\n }\n }\n ]\n }\n}",
"dataMode": "raw",
"description": "",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "id": "9d418a4b-197d-47c2-e85f-e68f6b5f5c40",
+ "headers": "Content-Type: application/json\n",
+ "id": "7412ee0c-b116-5cf1-0646-efa65f0da784",
"method": "GET",
- "name": "Sfc",
+ "name": "ietf-acl",
"responses": [],
"timestamp": 0,
- "url": "http://localhost:8181/restconf/config/netvirt-sfc:sfc/",
+ "url": "http://localhost:8181/restconf/config/ietf-access-control-list:access-lists",
"version": 2
},
{
"collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n \"access-lists\": {\n \"access-list\": [\n {\n \"acl-name\": \"http-acl\",\n \"access-list-entries\": {\n \"access-list-entry\": [\n {\n \"rule-name\": \"http-rule\",\n \"matches\": {\n \"destination-port-range\": {\n \"lower-port\": \"80\",\n \"upper-port\": \"80\"\n }\n },\n \"actions\": {\n \"permit\": {}\n }\n }\n ]\n }\n }\n ]\n }\n}",
+ "data": "{\n \"classifiers\": {\n \"classifier\": [\n {\n \"name\": \"http-classifier\",\n \"acl\": \"http-acl\",\n \"sffs\": {\n \"sff\": [\n {\n \"name\": \"sff1\"\n }\n ]\n }\n }\n ]\n }\n}",
+ "dataMode": "raw",
+ "description": "",
+ "headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
+ "id": "76b32432-5a24-9d6d-8ba2-76eb816411af",
+ "method": "DELETE",
+ "name": "Classifier",
+ "responses": [],
+ "timestamp": 0,
+ "url": "http://localhost:8181/restconf/config/netvirt-sfc-classifier:classifiers",
+ "version": 2
+ },
+ {
+ "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
+ "data": "{\n \"access-lists\": {\n \"acl\": [\n {\n \"acl-name\": \"http-acl\",\n \"access-list-entries\": {\n \"ace\": [\n {\n \"rule-name\": \"http-rule\",\n \"matches\": {\n \"destination-port-range\": {\n \"lower-port\": \"80\",\n \"upper-port\": \"80\"\n }\n },\n \"actions\": {\n \"netvirt-sfc-acl:redirect-sfc\": \"acl\"\n }\n }\n ]\n }\n }\n ]\n }\n}",
"dataMode": "raw",
"description": "",
"headers": "Content-Type: application/json\n",
- "id": "9e688730-6234-8f89-3de2-8a9974c4ea59",
- "method": "PUT",
- "name": "Acl",
- "time": 1444923678505,
+ "id": "99dc6bb5-f01a-64cd-a024-c333fdf82643",
+ "method": "DELETE",
+ "name": "ietf-acl redirect-sfc",
+ "responses": [],
"timestamp": 0,
- "url": "http://localhost:8181/restconf/config/ietf-acl:access-lists",
+ "url": "http://localhost:8181/restconf/config/ietf-access-control-list:access-lists",
+ "version": 2
+ },
+ {
+ "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
+ "data": "{\n\t\"sfc\": {\n \"name\": \"sfc1\"\n }\n}",
+ "dataMode": "raw",
+ "description": "",
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
+ "id": "9d418a4b-197d-47c2-e85f-e68f6b5f5c40",
+ "method": "GET",
+ "name": "Sfc",
+ "responses": [],
+ "timestamp": 0,
+ "url": "http://localhost:8181/restconf/config/netvirt-sfc:sfc/",
"version": 2
},
{
"id": "bf4f1148-5192-fd7d-3026-5a11668db75d",
"method": "PUT",
"name": "service-functions",
- "time": 1445035552080,
+ "time": 1445302596335,
"timestamp": 0,
- "url": "http://localhost:8181//restconf/config/service-function:service-functions",
+ "url": "http://localhost:8181/restconf/config/service-function:service-functions",
"version": 2
},
{
"collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n \"access-lists\": {\n \"access-list\": [\n {\n \"acl-name\": \"http-acl\",\n \"access-list-entries\": {\n \"access-list-entry\": [\n {\n \"rule-name\": \"http-rule\",\n \"matches\": {\n \"destination-port-range\": {\n \"lower-port\": \"80\",\n \"upper-port\": \"80\"\n }\n },\n \"actions\": {\n \"netvirt-sfc-acl:redirect-sfc\": \"acl\"\n }\n }\n ]\n }\n }\n ]\n }\n}",
+ "data": "{\n \"service-function-forwarders\": {\n \"service-function-forwarder\": [\n {\n \"name\": \"SFF1\",\n \"service-node\": \"OVSDB2\",\n \"service-function-forwarder-ovs:ovs-bridge\": {\n \"bridge-name\": \"sw2\"\n },\n \"service-function-dictionary\": [\n {\n \"name\": \"firewall-72\",\n \"type\": \"service-function-type:firewall\",\n \"sff-sf-data-plane-locator\": {\n \"port\": 6633,\n \"ip\": \"192.168.50.71\",\n \"transport\": \"service-locator:vxlan-gpe\"\n }\n }\n ],\n \"sff-data-plane-locator\": [\n {\n \"name\": \"sfc-tun2\",\n \"data-plane-locator\": {\n \"transport\": \"service-locator:vxlan-gpe\",\n \"port\": 6633,\n \"ip\": \"192.168.50.71\"\n },\n \"service-function-forwarder-ovs:ovs-options\": {\n \"remote-ip\": \"flow\",\n \"dst-port\": \"6633\",\n \"key\": \"flow\",\n \"nsp\": \"flow\",\n \"nsi\": \"flow\",\n \"nshc1\": \"flow\",\n \"nshc2\": \"flow\",\n \"nshc3\": \"flow\",\n \"nshc4\": \"flow\"\n }\n }\n ]\n },\n {\n \"name\": \"SFF2\",\n \"service-node\": \"OVSDB2\",\n \"service-function-forwarder-ovs:ovs-bridge\": {\n \"bridge-name\": \"sw4\"\n },\n \"service-function-dictionary\": [\n {\n \"name\": \"dpi-74\",\n \"type\": \"service-function-type:dpi\",\n \"sff-sf-data-plane-locator\": {\n \"port\": 6633,\n \"ip\": \"192.168.50.73\",\n \"transport\": \"service-locator:vxlan-gpe\"\n }\n }\n ],\n \"sff-data-plane-locator\": [\n {\n \"name\": \"sfc-tun4\",\n \"data-plane-locator\": {\n \"transport\": \"service-locator:vxlan-gpe\",\n \"port\": 6633,\n \"ip\": \"192.168.50.73\"\n },\n \"service-function-forwarder-ovs:ovs-options\": {\n \"remote-ip\": \"flow\",\n \"dst-port\": \"6633\",\n \"key\": \"flow\",\n \"nsp\": \"flow\",\n \"nsi\": \"flow\",\n \"nshc1\": \"flow\",\n \"nshc2\": \"flow\",\n \"nshc3\": \"flow\",\n \"nshc4\": \"flow\"\n }\n }\n ]\n }\n ]\n }\n}",
"dataMode": "raw",
"description": "",
- "headers": "Content-Type: application/json\n",
- "id": "c3d5a025-23c6-af23-dce1-9edca74cd65c",
- "method": "PUT",
- "name": "Acl - redirect-sfc",
- "time": 1445027841460,
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
+ "id": "e6542ed1-832c-71c9-fe74-2d25c9e7f7ad",
+ "method": "GET",
+ "name": "service-function-forwarders",
+ "responses": [],
"timestamp": 0,
- "url": "http://localhost:8181/restconf/config/ietf-acl:access-lists",
+ "url": "http://localhost:8181/restconf/config/service-function-forwarder:service-function-forwarders",
"version": 2
},
{
--- /dev/null
+{
+ "id":"19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "name":"Ovsdb HwvtepSouthbound",
+ "timestamp":1424977469540,
+ "order":[
+ "e9ff6957-4dc2-9257-c0c6-21560bfd5de2",
+ "ee151670-85a0-30ec-b22b-5defe7b66e0b",
+ "6de1ede7-817c-ccbb-3df9-ef510bdaf583",
+ "6e7c88e4-485d-ab9f-4c3a-cc235e022905",
+ "92ee7422-5b08-6d63-2b95-961ec0e18ffa",
+ "e92ac963-daaf-0899-c3e8-a00d897be0e2",
+ "9bc22ca7-049c-af51-7c12-6bf71044b2ec",
+ "f6d300f7-380a-d090-0d4a-2b2ddefe5104",
+ "f9f71d74-a49d-b190-d929-b6772ce0ba73",
+ "18032e93-3bc5-9976-4525-fe1e77e98207",
+ "22354294-1d01-cebf-180c-d609747be9bc",
+ "c8e8f3fd-3bfb-aafa-e3ec-a671a942f426",
+ "d362ddc4-1c5f-67d5-e354-c2a8d2ba9d79",
+ "538c71b3-e3e6-f01b-cc4c-d2b686686aa8"
+ ],
+ "owner":0,
+ "sharedWithTeam":false,
+ "synced":false,
+ "subscribed":false,
+ "hasRequests":true,
+ "requests":[
+ {
+ "collectionId":"19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id":"18032e93-3bc5-9976-4525-fe1e77e98207",
+ "name":"Delete Specific Config Logical Switch",
+ "description":"This restconf request delete specific logical switch from the config data store.",
+ "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2Flogicalswitch%2Fls0",
+ "method":"DELETE",
+ "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
+ "data":[],
+ "dataMode":"params",
+ "timestamp":0,
+ "version":2,
+ "time":1447335528744
+ },
+ {
+ "collectionId":"19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id":"22354294-1d01-cebf-180c-d609747be9bc",
+ "name":"Get All Operational Topology",
+ "description":"This restconf request will fetch the operational topology. Operational topology details are fetch by hwvtepsouthbound plugin from all the connected hwvtep node.",
+ "url":"http://{{controllerHost}}:8181/restconf/operational/network-topology:network-topology/",
+ "method":"GET",
+ "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
+ "data":[],
+ "dataMode":"params",
+ "timestamp":0,
+ "version":2
+ },
+ {
+ "collectionId":"19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id":"538c71b3-e3e6-f01b-cc4c-d2b686686aa8",
+ "name":"Get Specific Operational Logical Switch",
+ "description":"This restconf request fetch the operational for specific Logical Switch",
+ "url":"http://{{controllerHost}}:8181/restconf/operational/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2logicalswitch%2ls0",
+ "method":"GET",
+ "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
+ "data":"{\n \"network-topology:node\": [\n {\n \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640/logicalswitch/ls0\",\n \"hwvtep-node-description\": \"\",\n \"hwvtep-node-name\": \"ls0\",\n \"tunnel-key\": \"10000\"\n }\n ]\n}",
+ "dataMode":"raw",
+ "timestamp":0,
+ "version":2,
+ "time":1447335701900
+ },
+ {
+ "collectionId":"19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id":"6de1ede7-817c-ccbb-3df9-ef510bdaf583",
+ "name":"Create Specific Config HwvtepNode",
+ "description":"Fire this Restconf request if you want to initiate the connection to hwvtep node from controller. It assumes that hwvtep node is listening for tcp connection in passive mode.",
+ "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/",
+ "method":"POST",
+ "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
+ "data":"{\n \"network-topology:node\": [\n {\n \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640\",\n \"connection-info\": {\n \"hwvtep:remote-port\": 6640,\n \"hwvtep:remote-ip\": \"{{hwvtepNodeIp}}\"\n }\n }\n ]\n}",
+ "dataMode":"raw",
+ "timestamp":0,
+ "version":2,
+ "time":1447334840814
+ },
+ {
+ "collectionId":"19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id":"6e7c88e4-485d-ab9f-4c3a-cc235e022905",
+ "name":"Update Specific Config HwvtepNode",
+ "description":"Fire this Restconf request if you want to update the connection to Hwvtep node from controller.",
+ "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640",
+ "method":"PUT",
+ "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
+ "data":"{\n \"network-topology:node\": [\n {\n \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640\",\n \"connection-info\": {\n \"hwvtep:remote-port\": 6640,\n \"hwvtep:remote-ip\": \"{{hwvtepNodeIp}}\"\n }\n }\n ]\n}",
+ "dataMode":"raw",
+ "timestamp":0,
+ "version":2,
+ "time":1447334483164
+ },
+ {
+ "collectionId":"19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id":"92ee7422-5b08-6d63-2b95-961ec0e18ffa",
+ "name":"Get Specific Config HwvtepNode",
+ "description":"This restconf request fetch the configration for specific hwvtep node.",
+ "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640",
+ "method":"GET",
+ "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
+ "data":"{\n \"network-topology:node\": [\n {\n \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640\",\n \"connection-info\": {\n \"hwvtep:remote-port\": 6640,\n \"hwvtep:remote-ip\": \"{{hwvtepNodeIp}}\"\n }\n }\n ]\n}",
+ "dataMode":"raw",
+ "timestamp":0,
+ "version":2,
+ "time":1447334914971
+ },
+ {
+ "collectionId":"19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id":"9bc22ca7-049c-af51-7c12-6bf71044b2ec",
+ "name":"Create Specific Config Logical Switch",
+ "description":"Fire this Restconf request if you want to create a logical switch.",
+ "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/",
+ "method":"POST",
+ "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
+ "data":"{\n \"network-topology:node\": [\n {\n \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640/logicalswitch/ls0\",\n \"hwvtep-node-description\": \"\",\n \"hwvtep-node-name\": \"ls0\",\n \"tunnel-key\": \"10000\",\n \"managed-by\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']\" \n }\n ]\n}",
+ "dataMode":"raw",
+ "timestamp":0,
+ "version":2,
+ "time":1447340822378
+ },
+ {
+ "collectionId":"19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id":"c8e8f3fd-3bfb-aafa-e3ec-a671a942f426",
+ "name":"Get Operational Hwvtep Topology",
+ "description":"",
+ "url":"http://{{controllerHost}}:8181/restconf/operational/network-topology:network-topology/topology/hwvtep:1/",
+ "method":"GET",
+ "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
+ "data":"{\n \"network-topology:node\": [\n {\n \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640\",\n \"connection-info\": {\n \"hwvtep:remote-port\": 6640,\n \"hwvtep:remote-ip\": \"{{hwvtepNodeIp}}\"\n }\n }\n ]\n}",
+ "dataMode":"raw",
+ "timestamp":0,
+ "version":2,
+ "time":1447335830695
+ },
+ {
+ "collectionId":"19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id":"d362ddc4-1c5f-67d5-e354-c2a8d2ba9d79",
+ "name":"Get Specific Operational HwvtepNode",
+ "description":"This restconf request fetch the operational for specific HwvtepNode",
+ "url":"http://{{controllerHost}}:8181/restconf/operational/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640",
+ "method":"GET",
+ "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
+ "data":"{\n \"network-topology:node\": [\n {\n \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640/logicalswitch/ls0\",\n \"hwvtep-node-description\": \"\",\n \"hwvtep-node-name\": \"ls0\",\n \"tunnel-key\": \"10000\"\n }\n ]\n}",
+ "dataMode":"raw",
+ "timestamp":0,
+ "version":2,
+ "time":1447335686540
+ },
+ {
+ "collectionId":"19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id":"e92ac963-daaf-0899-c3e8-a00d897be0e2",
+ "name":"Delete Specific Config HwvtepNode",
+ "description":"This restconf request delete any node (ovsdb node or bridge node) from the config data store. You can use the same request to delete the ovsdb node by using the following URI: http://localhost:8080/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F10.10.10.10:22222",
+ "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640",
+ "method":"DELETE",
+ "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
+ "data":[],
+ "dataMode":"params",
+ "timestamp":0,
+ "version":2
+ },
+ {
+ "collectionId":"19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id":"e9ff6957-4dc2-9257-c0c6-21560bfd5de2",
+ "name":"Get All Config Topology",
+ "description":"Fetch all the config topology from configuration data store.",
+ "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/",
+ "method":"GET",
+ "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
+ "data":"{\n \"network-topology:node\": [\n {\n \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640\",\n \"connection-info\": {\n \"hwvtep:remote-port\": 6640,\n \"hwvtep:remote-ip\": \"{{hwvtepNodeIp}}\"\n }\n }\n ]\n}",
+ "dataMode":"raw",
+ "timestamp":0,
+ "version":2,
+ "time":1447311894927
+ },
+ {
+ "collectionId":"19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id":"ee151670-85a0-30ec-b22b-5defe7b66e0b",
+ "name":"Get Config Hwvtep Topology",
+ "description":"Fetch the config hwvtep topology from configuration data store.",
+ "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/hwvtep:1/",
+ "method":"GET",
+ "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
+ "data":"{\n \"network-topology:node\": [\n {\n \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640\",\n \"connection-info\": {\n \"hwvtep:remote-port\": 6640,\n \"hwvtep:remote-ip\": \"{{hwvtepNodeIp}}\"\n }\n }\n ]\n}",
+ "dataMode":"raw",
+ "timestamp":0,
+ "version":2,
+ "time":1447335823182
+ },
+ {
+ "collectionId":"19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id":"f6d300f7-380a-d090-0d4a-2b2ddefe5104",
+ "name":"Create Specific Config Logical Switch",
+ "description":"Fire this request if you want to update specific logical switch.",
+ "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2Flogicalswitch%2Fls0",
+ "method":"PUT",
+ "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
+ "data":"{\n \"network-topology:node\": [\n {\n \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640/logicalswitch/ls0\",\n \"hwvtep-node-description\": \"\",\n \"hwvtep-node-name\": \"ls0\",\n \"tunnel-key\": \"10000\",\n \"managed-by\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']\" \n }\n ]\n}",
+ "dataMode":"raw",
+ "timestamp":0,
+ "version":2,
+ "time":1447340847211
+ },
+ {
+ "collectionId":"19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id":"f9f71d74-a49d-b190-d929-b6772ce0ba73",
+ "name":"Get Specific Config Logical Switch",
+ "description":"This restconf request fetch configuration for specific logical switch.",
+ "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2Flogicalswitch%2Fls0",
+ "method":"GET",
+ "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
+ "data":"{\n \"network-topology:node\": [\n {\n \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640/logicalswitch/ls0\",\n \"hwvtep-node-description\": \"\",\n \"hwvtep-node-name\": \"ls0\",\n \"tunnel-key\": \"10000\"\n }\n ]\n}",
+ "dataMode":"raw",
+ "timestamp":0,
+ "version":2,
+ "time":1447335408595
+ }
+ ]
+}
- showOvsdbMdsal.py : Dumps mdsal related info from running ODL that is related to ovsdb and netvirt. Use 'showOvsdbMdsal.py -h' for usage
- ODL-Clustering.json.postman_collection : Collection contains Restconf request to fetch clustering service related data to check the state of 3 node cluster and inventory/topology shards.
- - Please import and load 3-Node-Cluster-Setup-Environment-Variables.postman_environment file, because Restconf request present in this collection depends on the variable defined in this collection.
+ - Please import and load 3-Node-Cluster-Setup-Environment-Variables.postman_environment file, because Restconf request present in this collection depends on the variable defined in this collection.
- Ovsdb-Southbound-Collection-for-Single-Node-Cluster.json.postman_collection : Collection contains Restconf request for doing CRUD operations (connection, bridge, termination point) on southbound plugin running in standalone controller.
- - Please import and load Single-Node-Cluster-Setup-Environment-Variables.postman_environment file, because Restconf request present in this collection depends on the variable defined in this collection.
+ - Please import and load Single-Node-Cluster-Setup-Environment-Variables.postman_environment file, because Restconf request present in this collection depends on the variable defined in this collection.
-- Ovsdb-Southbound-Collection-for-3-Node-Cluster.json.postman_collection :
- - Please import and load 3-Node-Cluster-Setup-Environment-Variables.postman_environment file, because Restconf request present in this collection depends on the variable defined in this collection.
+- Ovsdb-Southbound-Collection-for-3-Node-Cluster.json.postman_collection :
+ - Please import and load 3-Node-Cluster-Setup-Environment-Variables.postman_environment file, because Restconf request present in this collection depends on the variable defined in this collection.
- Single-Node-Cluster-Setup-Environment-Variables.postman_environment : Postman environment file that defines variables for Restconf request for southbound plugin running in Single controller instance
- 3-Node-Cluster-Setup-Environment-Variables.postman_environment : Postman environment file that defines variables for Restconf request for southbound plugin running in 3 node cluster environment
- NetvirtSfc.json.postman_collection : Collection of REST-APIs to interact with Netvirt-Sfc.
+
+- Ovsdb-HwvtepSouthbound-Collection.json.postman_collection : Collection contains Restconf request for doing CRUD operations (hwvtep global node, physical switch, logical switch, physical locator, and physical port) on hwvtepsouthbound plugin running in standalone controller.
public class StringConvertor{
public static long dpidStringToLong(String values) {
- long value = new BigInteger(values.replaceAll(":", ""), 16).longValue();
- return value;
+ return new BigInteger(values.replaceAll(":", ""), 16).longValue();
}
}
<groupId>org.opendaylight.mdsal.model</groupId>
<artifactId>opendaylight-l2-types</artifactId>
</dependency>
- <!-- Controller Dependencies -->
<dependency>
<groupId>org.opendaylight.openflowplugin</groupId>
<artifactId>openflowjava-extension-nicira</artifactId>
</dependencies>
<build>
<plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.opendaylight.ovsdb.utils.mdsal.openflow
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
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.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.DstChoice;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxArpShaCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxArpThaCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxRegCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIdCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIpv4DstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpOpCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpSpaCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpTpaCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfEthDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.*;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.group.buckets.bucket.action.action.NxActionRegLoadNodesNodeGroupBucketsBucketActionsCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.group.buckets.bucket.action.action.NxActionRegMoveNodesNodeGroupBucketsBucketActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionOutputRegNodesNodeTableFlowApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegMoveNodesNodeTableFlowApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.*;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.NxOutputReg;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.NxOutputRegBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoad;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMove;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMoveBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.SrcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._1.grouping.NxSetNshc1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._1.grouping.NxSetNshc1Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._2.grouping.NxSetNshc2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._2.grouping.NxSetNshc2Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._3.grouping.NxSetNshc3;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._3.grouping.NxSetNshc3Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._4.grouping.NxSetNshc4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._4.grouping.NxSetNshc4Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.SrcChoice;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxArpShaCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc1CaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc2CaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxRegCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIdCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIpv4DstCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfArpSpaCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfEthSrcCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.OfjNxHashFields;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.OfjNxMpAlgorithm;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionMultipathNodesNodeTableFlowApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionResubmitNodesNodeTableFlowApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionSetNsiNodesNodeTableFlowApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionSetNspNodesNodeTableFlowApplyActionsCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.NxMultipath;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.NxMultipathBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.resubmit.grouping.NxResubmit;
NxRegLoad r = new NxRegLoadBuilder()
.setDst(new DstBuilder()
.setDstChoice(dstChoice)
- .setStart(Integer.valueOf(0))
- .setEnd(Integer.valueOf(endOffset))
+ .setStart(0)
+ .setEnd(endOffset)
.build())
.setValue(value)
.build();
NxRegMove r = new NxRegMoveBuilder()
.setSrc(new SrcBuilder()
.setSrcChoice(srcChoice)
- .setStart(Integer.valueOf(0))
- .setEnd(Integer.valueOf(endOffset))
+ .setStart(0)
+ .setEnd(endOffset)
.build())
.setDst(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.DstBuilder()
.setDstChoice(dstChoice)
- .setStart(Integer.valueOf(0))
- .setEnd(Integer.valueOf(endOffset))
+ .setStart(0)
+ .setEnd(endOffset)
.build())
.build();
if (groupBucket) {
public static Action nxMoveRegTunIdAction(Class<? extends NxmNxReg> src,
boolean groupBucket) {
- return nxMoveRegAction(new SrcNxRegCaseBuilder()
- .setNxReg(src).build(),
- new DstNxTunIdCaseBuilder()
- .setNxTunId(Boolean.TRUE).build(),
+ return nxMoveRegAction(new SrcNxRegCaseBuilder().setNxReg(src).build(),
+ new DstNxTunIdCaseBuilder().setNxTunId(Boolean.TRUE).build(),
31,
groupBucket);
}
public static Action nxMoveArpShaToArpThaAction() {
- return nxMoveRegAction(new SrcNxArpShaCaseBuilder()
- .setNxArpSha(Boolean.TRUE).build(),
- new DstNxArpThaCaseBuilder()
- .setNxArpTha(Boolean.TRUE).build(),
+ return nxMoveRegAction(new SrcNxArpShaCaseBuilder().setNxArpSha(Boolean.TRUE).build(),
+ new DstNxArpThaCaseBuilder().setNxArpTha(Boolean.TRUE).build(),
47, false);
}
public static Action nxMoveEthSrcToEthDstAction() {
- return nxMoveRegAction(new SrcOfEthSrcCaseBuilder()
- .setOfEthSrc(Boolean.TRUE).build(),
- new DstOfEthDstCaseBuilder()
- .setOfEthDst(Boolean.TRUE).build(),
+ return nxMoveRegAction(new SrcOfEthSrcCaseBuilder().setOfEthSrc(Boolean.TRUE).build(),
+ new DstOfEthDstCaseBuilder().setOfEthDst(Boolean.TRUE).build(),
47, false);
}
public static Action nxMoveArpSpaToArpTpaAction() {
- return nxMoveRegAction(new SrcOfArpSpaCaseBuilder()
- .setOfArpSpa(Boolean.TRUE).build(),
- new DstOfArpTpaCaseBuilder()
- .setOfArpTpa(Boolean.TRUE).build());
+ return nxMoveRegAction(new SrcOfArpSpaCaseBuilder().setOfArpSpa(Boolean.TRUE).build(),
+ new DstOfArpTpaCaseBuilder().setOfArpTpa(Boolean.TRUE).build());
}
public static Action nxOutputRegAction(SrcChoice srcChoice) {
NxOutputReg r = new NxOutputRegBuilder()
.setSrc(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.SrcBuilder()
.setSrcChoice(srcChoice)
- .setOfsNbits(Integer.valueOf(31))
+ .setOfsNbits(31)
.build())
- .setMaxLen(Integer.valueOf(0xffff))
+ .setMaxLen(0xffff)
.build();
return new NxActionOutputRegNodesNodeTableFlowApplyActionsCaseBuilder()
.setNxOutputReg(r).build();
return new NxActionSetNspNodesNodeTableFlowApplyActionsCaseBuilder().setNxSetNsp(r).build();
}
- public static Action nxSetNsiAction(Short nsp) {
+ public static Action nxSetNsiAction(Short nsi) {
NxSetNsiBuilder builder = new NxSetNsiBuilder();
- if (nsp != null) {
- builder.setNsi(nsp);
+ if (nsi != null) {
+ builder.setNsi(nsi);
}
NxSetNsi r = builder.build();
return new NxActionSetNsiNodesNodeTableFlowApplyActionsCaseBuilder().setNxSetNsi(r).build();
}
+ public static Action nxLoadNshc1RegAction(Long value) {
+ NxSetNshc1 newNshc1 = new NxSetNshc1Builder().setNshc(value).build();
+ return new NxActionSetNshc1NodesNodeTableFlowApplyActionsCaseBuilder().setNxSetNshc1(newNshc1).build();
+ }
+
+ public static Action nxLoadNshc2RegAction(Long value) {
+ NxSetNshc2 newNshc2 = new NxSetNshc2Builder().setNshc(value).build();
+ return new NxActionSetNshc2NodesNodeTableFlowApplyActionsCaseBuilder().setNxSetNshc2(newNshc2).build();
+ }
+
+ public static Action nxLoadNshc3RegAction(Long value) {
+ NxSetNshc3 newNshc3 = new NxSetNshc3Builder().setNshc(value).build();
+ return new NxActionSetNshc3NodesNodeTableFlowApplyActionsCaseBuilder().setNxSetNshc3(newNshc3).build();
+ }
+
+ public static Action nxLoadNshc4RegAction(Long value) {
+ NxSetNshc4 newNshc4 = new NxSetNshc4Builder().setNshc(value).build();
+ return new NxActionSetNshc4NodesNodeTableFlowApplyActionsCaseBuilder().setNxSetNshc4(newNshc4).build();
+ }
+
+ public static Action nxMoveRegTunDstToNshc1() {
+ return nxMoveRegAction(
+ new SrcNxTunIpv4DstCaseBuilder().setNxTunIpv4Dst(Boolean.TRUE).build(),
+ new DstNxNshc1CaseBuilder().setNxNshc1Dst(Boolean.TRUE).build(),
+ 31, false);
+ }
+
+ public static Action nxMoveTunIdtoNshc2() {
+ return nxMoveRegAction(
+ new SrcNxTunIdCaseBuilder().setNxTunId(Boolean.TRUE).build(),
+ new DstNxNshc2CaseBuilder().setNxNshc2Dst(Boolean.TRUE).build(),
+ 31, false);
+ }
+
+ public static Action nxMoveNshc1ToTunIpv4Dst() {
+ return nxMoveRegAction(
+ new SrcNxNshc1CaseBuilder().setNxNshc1Dst(Boolean.TRUE).build(),
+ new DstNxTunIpv4DstCaseBuilder().setNxTunIpv4Dst(Boolean.TRUE).build(),
+ 31, false);
+ }
+
+ public static Action nxMoveNshc2ToTunId() {
+ return nxMoveRegAction(
+ new SrcNxNshc2CaseBuilder().setNxNshc2Dst(Boolean.TRUE).build(),
+ new DstNxTunIdCaseBuilder().setNxTunId(Boolean.TRUE).build(),
+ 31, false);
+ }
+
+ public static Action nxLoadTunIdAction(BigInteger tunnelId, boolean groupBucket) {
+ return nxLoadRegAction(new DstNxTunIdCaseBuilder().setNxTunId(Boolean.TRUE).build(), tunnelId, 31, groupBucket);
+ }
+
public static Action nxMultipathAction(OfjNxHashFields fields, Integer basis,
OfjNxMpAlgorithm algorithm, Integer maxLink, Long arg, DstChoice dstChoice,
Integer start, Integer end) {
--- /dev/null
+/*
+ * Copyright (c) 2015 Red Hat, 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.ovsdb.utils.mdsal.openflow;
+
+import com.google.common.base.Optional;
+import java.util.concurrent.ExecutionException;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg0;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FlowUtils {
+ private static final Logger LOG = LoggerFactory.getLogger(FlowUtils.class);
+ private static final String OPENFLOW = "openflow";
+ public final static long REG_VALUE_FROM_LOCAL = 0x1L;
+ public final static long REG_VALUE_FROM_REMOTE = 0x2L;
+ public static final Class<? extends NxmNxReg> REG_FIELD = NxmNxReg0.class;
+ public static final int ARP_OP_REQUEST = 0x1;
+ public static final int ARP_OP_REPLY = 0x2;
+
+
+ public static String getNodeName(long dpidLong) {
+ return OPENFLOW + ":" + dpidLong;
+ }
+
+ public static NodeConnectorId getNodeConnectorId(long ofPort, String nodeName) {
+ return new NodeConnectorId(nodeName + ":" + ofPort);
+ }
+
+ public static NodeConnectorId getSpecialNodeConnectorId(long dpidLong, String portName) {
+ return new NodeConnectorId(getNodeName(dpidLong) + ":" + portName);
+ }
+
+ public static NodeConnectorId getNodeConnectorId(long dpidLong, long ofPort) {
+ return getNodeConnectorId(ofPort, getNodeName(dpidLong));
+ }
+
+ public static NodeBuilder createNodeBuilder(String nodeId) {
+ NodeBuilder builder = new NodeBuilder();
+ builder.setId(new NodeId(nodeId));
+ builder.setKey(new NodeKey(builder.getId()));
+ return builder;
+ }
+
+ public static NodeBuilder createNodeBuilder(long dpidLong) {
+ return createNodeBuilder(getNodeName(dpidLong));
+ }
+
+ public static InstanceIdentifier<Flow> createFlowPath(FlowBuilder flowBuilder, NodeBuilder nodeBuilder) {
+ return InstanceIdentifier.builder(Nodes.class)
+ .child(Node.class, nodeBuilder.getKey())
+ .augmentation(FlowCapableNode.class)
+ .child(Table.class, new TableKey(flowBuilder.getTableId()))
+ .child(Flow.class, flowBuilder.getKey()).build();
+ }
+
+ public static InstanceIdentifier<Node> createNodePath(NodeBuilder nodeBuilder) {
+ return InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeBuilder.getKey()).build();
+ }
+
+ public static Flow getFlow(FlowBuilder flowBuilder, NodeBuilder nodeBuilder,
+ ReadOnlyTransaction readTx, final LogicalDatastoreType store) {
+ try {
+ Optional<Flow> data = readTx.read(store, createFlowPath(flowBuilder, nodeBuilder)).get();
+ if (data.isPresent()) {
+ return data.get();
+ }
+ } catch (InterruptedException|ExecutionException e) {
+ LOG.error(e.getMessage(), e);
+ }
+
+ LOG.info("Cannot find data for Flow {} in {}", flowBuilder.getFlowName(), store);
+ return null;
+ }
+
+ public static FlowBuilder getPipelineFlow(short table, short gotoTable) {
+ FlowBuilder flowBuilder = new FlowBuilder();
+ flowBuilder.setMatch(new MatchBuilder().build());
+
+ String flowId = "DEFAULT_PIPELINE_FLOW_" + table;
+ flowBuilder.setId(new FlowId(flowId));
+ FlowKey key = new FlowKey(new FlowId(flowId));
+ flowBuilder.setStrict(true);
+ flowBuilder.setBarrier(false);
+ flowBuilder.setTableId(table);
+ flowBuilder.setKey(key);
+ flowBuilder.setFlowName(flowId);
+ flowBuilder.setHardTimeout(0);
+ flowBuilder.setIdleTimeout(0);
+ flowBuilder.setPriority(0);
+ return flowBuilder;
+ }
+}
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
-import com.google.common.collect.Lists;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*/
public static InstructionBuilder createSendToControllerInstructions(String nodeName, InstructionBuilder ib) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
OutputActionBuilder output = new OutputActionBuilder();
public static InstructionBuilder createNormalInstructions(String nodeName, InstructionBuilder ib) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
OutputActionBuilder output = new OutputActionBuilder();
return ib;
}
+ /**
+ * Create LOCAL Reserved Port Instruction
+ *
+ * @param ib Map InstructionBuilder without any instructions
+ * @param dpidLong Long the datapath ID of a switch/node
+ * @return ib Map InstructionBuilder with instructions
+ */
+ public static InstructionBuilder createLocalInstructions(InstructionBuilder ib, long dpidLong) {
+ List<Action> actionList = new ArrayList<>();
+ ActionBuilder ab = new ActionBuilder();
+
+ OutputActionBuilder output = new OutputActionBuilder();
+ output.setOutputNodeConnector(new NodeConnectorId("openflow:" + dpidLong + ":"
+ + OutputPortValues.LOCAL.toString()));
+ ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
+ ab.setOrder(0);
+ ab.setKey(new ActionKey(0));
+ actionList.add(ab.build());
+
+ // Create an Apply Action
+ ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ aab.setAction(actionList);
+
+ // Wrap our Apply Action in an Instruction
+ ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+ return ib;
+ }
+
/**
* Create Output Port Instruction
*
LOG.debug("createOutputPortInstructions() Node Connector ID is - Type=openflow: DPID={} inPort={} ",
dpidLong, port);
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
OutputActionBuilder oab = new OutputActionBuilder();
oab.setOutputNodeConnector(ncid);
"addOutputPortInstructions() Node Connector ID is - Type=openflow: DPID={} port={} existingInstructions={}",
dpidLong, port, instructions);
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
List<Action> existingActions;
"removeOutputPortFromInstructions() Node Connector ID is - Type=openflow: DPID={} port={} existingInstructions={}",
dpidLong, port, instructions);
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab;
// Start of by locating actions that will have port removed, from the existing instructionList
*/
public static InstructionBuilder createSetVlanInstructions(InstructionBuilder ib, VlanId vlanId) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
/* First we push vlan header */
*/
public static InstructionBuilder createPopVlanInstructions(InstructionBuilder ib) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
*/
public static InstructionBuilder createNwSrcInstructions(InstructionBuilder ib, Ipv4Prefix prefixsrc) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
public static InstructionBuilder createNwDstInstructions(InstructionBuilder ib, Ipv4Prefix prefixdst,
ActionBuilder extraAction) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
ab.setKey(new ActionKey(0));
// Add our drop action to a list
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
actionList.add(ab.build());
// Create an Apply Action
*/
public static InstructionBuilder createSetTunnelIdInstructions(InstructionBuilder ib, BigInteger tunnelId) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
*/
public static InstructionBuilder createSetSrcTCPPort(InstructionBuilder ib, PortNumber tcpport) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
*/
public static InstructionBuilder createSetDstTCPPort(InstructionBuilder ib, PortNumber tcpport) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
*/
public static InstructionBuilder createSetSrcUDPPort(InstructionBuilder ib, PortNumber udpport) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
*/
public static InstructionBuilder createSetDstUDPPort(InstructionBuilder ib, PortNumber udpport) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
public static InstructionBuilder createSetIcmpCodeInstruction(InstructionBuilder ib, short code) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
*/
public static InstructionBuilder createSetIcmpTypeInstruction(InstructionBuilder ib, short type) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
ab.setKey(new ActionKey(0));
// Add our drop action to a list
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
actionList.add(ab.build());
// Create an Apply Action
*/
public static InstructionBuilder createSrcArpMacInstructions(InstructionBuilder ib, MacAddress macsrc) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
*/
public static InstructionBuilder createDstArpMacInstructions(InstructionBuilder ib, MacAddress macdst) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
*/
public static InstructionBuilder createDstArpIpInstructions(InstructionBuilder ib, Ipv4Prefix dstiparp) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
*/
public static InstructionBuilder createSrcArpIpInstructions(InstructionBuilder ib, Ipv4Prefix srciparp) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
*/
public static InstructionBuilder createTunnelIpv4SrcInstructions(InstructionBuilder ib, Ipv4Prefix srcIp) {
- List<Action> actionList = new ArrayList<Action>();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
// Build the tunnel endpoint source IPv4 address
*/
public static InstructionBuilder createTunnelIpv4DstInstructions(InstructionBuilder ib, Ipv4Prefix dstIp) {
- List<Action> actionList = new ArrayList<Action>();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
// Build the tunnel endpoint dst IPv4 address
public static InstructionBuilder createDlSrcInstructions(InstructionBuilder ib, MacAddress macAddress) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
SetDlSrcActionBuilder dlSrcActionBuilder= new SetDlSrcActionBuilder();
public static InstructionBuilder createDlDstInstructions(InstructionBuilder ib, MacAddress macAddress) {
- List<Action> actionList = Lists.newArrayList();
+ List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
SetDlDstActionBuilder dlDstActionBuilder= new SetDlDstActionBuilder();
public static List<Action>
actionList(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action... actions) {
- ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> alist
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> alist
= new ArrayList<>();
int count = 0;
for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action : actions) {
public static final String UDP = "udp";
private static final int TCP_SYN = 0x0002;
public static final String ICMP = "icmp";
+ public static final short ALL_ICMP = -1;
/**
* Create Ingress Port Match dpidLong, inPort
return matchBuilder;
}
+ public static MatchBuilder createInPortReservedMatch(MatchBuilder matchBuilder, Long dpidLong, String inPort) {
+
+ NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + inPort);
+ LOG.debug("createInPortResrevedMatch() Node Connector ID is - Type=openflow: DPID={} inPort={} ",
+ dpidLong, inPort);
+ matchBuilder.setInPort(NodeConnectorId.getDefaultInstance(ncid.getValue()));
+ matchBuilder.setInPort(ncid);
+
+ return matchBuilder;
+ }
+
/**
* Create EtherType Match
*
// Build the ICMPv4 Match
Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
- icmpv4match.setIcmpv4Type(type);
- icmpv4match.setIcmpv4Code(code);
+ if (type != ALL_ICMP || code != ALL_ICMP) {
+ icmpv4match.setIcmpv4Type(type);
+ icmpv4match.setIcmpv4Code(code);
+ }
matchBuilder.setIcmpv4Match(icmpv4match.build());
return matchBuilder;
*/
public static MatchBuilder createArpDstIpv4Match(MatchBuilder matchBuilder, Ipv4Prefix dstip) {
ArpMatchBuilder arpDstMatch = new ArpMatchBuilder();
- arpDstMatch.setArpTargetTransportAddress(dstip);
+ arpDstMatch.setArpTargetTransportAddress(dstip)
+ .setArpOp(FlowUtils.ARP_OP_REQUEST);
matchBuilder.setLayer3Match(arpDstMatch.build());
return matchBuilder;
}
}
- public static void addNxRegMatch(MatchBuilder match,
- RegMatch... matches) {
+ public static MatchBuilder addNxRegMatch(MatchBuilder matchBuilder, RegMatch... matches) {
List<ExtensionList> extensions = new ArrayList<>();
for (RegMatch rm : matches) {
Class<? extends ExtensionKey> key;
}
NxAugMatchNodesNodeTableFlow am =
new NxAugMatchNodesNodeTableFlowBuilder()
- .setNxmNxReg(new NxmNxRegBuilder()
- .setReg(rm.reg)
- .setValue(rm.value)
- .build())
- .build();
+ .setNxmNxReg(new NxmNxRegBuilder()
+ .setReg(rm.reg)
+ .setValue(rm.value)
+ .build())
+ .build();
extensions.add(new ExtensionListBuilder()
- .setExtensionKey(key)
- .setExtension(new ExtensionBuilder()
- .addAugmentation(NxAugMatchNodesNodeTableFlow.class, am)
- .build())
- .build());
+ .setExtensionKey(key)
+ .setExtension(new ExtensionBuilder()
+ .addAugmentation(NxAugMatchNodesNodeTableFlow.class, am)
+ .build())
+ .build());
}
- GeneralAugMatchNodesNodeTableFlow m =
- new GeneralAugMatchNodesNodeTableFlowBuilder()
- .setExtensionList(extensions)
- .build();
- match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
+ GeneralAugMatchNodesNodeTableFlow m = new GeneralAugMatchNodesNodeTableFlowBuilder()
+ .setExtensionList(extensions)
+ .build();
+ matchBuilder.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
+ return matchBuilder;
}
- public static void addNxTunIdMatch(MatchBuilder match,
- int tunId) {
- NxAugMatchNodesNodeTableFlow am =
- new NxAugMatchNodesNodeTableFlowBuilder()
- .setNxmNxTunId(new NxmNxTunIdBuilder()
- .setValue(BigInteger.valueOf(tunId))
- .build())
- .build();
+ public static MatchBuilder addNxTunIdMatch(MatchBuilder matchBuilder, int tunId) {
+ NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
+ .setNxmNxTunId(new NxmNxTunIdBuilder()
+ .setValue(BigInteger.valueOf(tunId))
+ .build())
+ .build();
GeneralAugMatchNodesNodeTableFlow m =
new GeneralAugMatchNodesNodeTableFlowBuilder()
- .setExtensionList(ImmutableList.of(new ExtensionListBuilder()
- .setExtensionKey(NxmNxTunIdKey.class)
- .setExtension(new ExtensionBuilder()
- .addAugmentation(NxAugMatchNodesNodeTableFlow.class, am)
- .build())
- .build()))
- .build();
- match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
+ .setExtensionList(ImmutableList.of(new ExtensionListBuilder()
+ .setExtensionKey(NxmNxTunIdKey.class)
+ .setExtension(new ExtensionBuilder()
+ .addAugmentation(NxAugMatchNodesNodeTableFlow.class, am)
+ .build())
+ .build()))
+ .build();
+ matchBuilder.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
+ return matchBuilder;
}
- public static void addNxNsp(MatchBuilder match, long nsp) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow am =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder()
+ public static MatchBuilder addNxNspMatch(MatchBuilder matchBuilder, long nsp) {
+ NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
.setNxmNxNsp(new NxmNxNspBuilder()
- .setValue(nsp)
- .build())
+ .setValue(nsp)
+ .build())
.build();
- addExtension(match, NxmNxNspKey.class, am);
+ addExtension(matchBuilder, NxmNxNspKey.class, am);
+ return matchBuilder;
}
- public static void addNxNsi(MatchBuilder match, short nsi) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow am =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder()
+ public static MatchBuilder addNxNsiMatch(MatchBuilder matchBuilder, short nsi) {
+ NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
.setNxmNxNsi(new NxmNxNsiBuilder()
- .setNsi(nsi)
- .build())
+ .setNsi(nsi)
+ .build())
.build();
- addExtension(match, NxmNxNsiKey.class, am);
+ addExtension(matchBuilder, NxmNxNsiKey.class, am);
+ return matchBuilder;
}
- private static void addExtension (MatchBuilder match, Class<? extends ExtensionKey> extensionKey, org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow am) {
- GeneralAugMatchNodesNodeTableFlow existingAugmentations = match.getAugmentation(GeneralAugMatchNodesNodeTableFlow.class);
+ private static void addExtension(MatchBuilder matchBuilder, Class<? extends ExtensionKey> extensionKey,
+ NxAugMatchNodesNodeTableFlow am) {
+ GeneralAugMatchNodesNodeTableFlow existingAugmentations =
+ matchBuilder.getAugmentation(GeneralAugMatchNodesNodeTableFlow.class);
List<ExtensionList> extensions = null;
if (existingAugmentations != null ) {
extensions = existingAugmentations.getExtensionList();
}
extensions.add(new ExtensionListBuilder()
- .setExtensionKey(extensionKey)
- .setExtension(new ExtensionBuilder()
- .addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow.class, am)
- .build())
- .build());
+ .setExtensionKey(extensionKey)
+ .setExtension(new ExtensionBuilder()
+ .addAugmentation(NxAugMatchNodesNodeTableFlow.class, am)
+ .build())
+ .build());
GeneralAugMatchNodesNodeTableFlow m = new GeneralAugMatchNodesNodeTableFlowBuilder()
- .setExtensionList(extensions)
- .build();
- match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
+ .setExtensionList(extensions)
+ .build();
+ matchBuilder.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
}
public static EthernetMatch ethernetMatch(MacAddress srcMac,
<version>1.2.1-SNAPSHOT</version>
<packaging>bundle</packaging>
+ <developers>
+ <developer>
+ <name>Anil Vishnoi</name>
+ <email>vishnoianil@gmail.com</email>
+ <url>https://github.com/vishnoianil</url>
+ </developer>
+ </developers>
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/ovsdb.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/ovsdb.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://wiki.opendaylight.org/view/OVSDB_Integration:Main</url>
+ </scm>
+
+ <properties>
+ <neutron.model.version>0.6.0-SNAPSHOT</neutron.model.version>
+ </properties>
+
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.neutron</groupId>
+ <artifactId>model</artifactId>
+ <version>${neutron.model.version}</version>
+ </dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.opendaylight.ovsdb.utils.mdsal.utils
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2015 Brocade Communications 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.ovsdb.utils.mdsal.utils;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NeutronModelsDataStoreHelper {
+
+ private static final Logger LOG = LoggerFactory.getLogger(MdsalUtils.class);
+ private DataBroker databroker = null;
+ private MdsalUtils mdsalClient = null;
+
+ /**
+ * Class constructor setting the data broker.
+ *
+ * @param dataBroker the {@link org.opendaylight.controller.md.sal.binding.api.DataBroker}
+ */
+ public NeutronModelsDataStoreHelper(DataBroker dataBroker) {
+ this.databroker = dataBroker;
+ this.mdsalClient = new MdsalUtils(this.databroker);
+ }
+
+ public Routers readAllNeutronRouters() {
+ Routers routers = this.mdsalClient.read(LogicalDatastoreType.CONFIGURATION, getNeutrounRoutersPath());
+ if(routers != null ) {
+ LOG.debug("{} routers present in data store", routers.getRouter()!=null? routers.getRouter().size():0);
+ }
+ return routers;
+ }
+
+ public Ports readAllNeutronPorts() {
+ Ports ports = this.mdsalClient.read(LogicalDatastoreType.CONFIGURATION, getNeutrounPortsPath());
+ if(ports != null ) {
+ LOG.debug("{} ports present in data store", ports.getPort()!=null? ports.getPort().size():0);
+ }
+ return ports;
+ }
+ public Port readNeutronPort(Uuid portId) {
+ Port mdsalPort = this.mdsalClient.read(LogicalDatastoreType.CONFIGURATION, getNeutronPortPath(portId));
+ if (mdsalPort != null) {
+ LOG.debug("Port {} fetched from config data store for router interface {}",mdsalPort, portId);
+ }
+ return mdsalPort;
+ }
+
+ private InstanceIdentifier<Routers> getNeutrounRoutersPath() {
+ return InstanceIdentifier
+ .create(Neutron.class)
+ .child(Routers.class);
+ }
+
+ private InstanceIdentifier<Ports> getNeutrounPortsPath() {
+ return InstanceIdentifier
+ .create(Neutron.class)
+ .child(Ports.class);
+ }
+
+ private InstanceIdentifier<Port> getNeutronPortPath(Uuid portId) {
+ return InstanceIdentifier
+ .create(Neutron.class)
+ .child(Ports.class)
+ .child(Port.class,new PortKey(portId));
+ }
+}
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.opendaylight.ovsdb.utils.servicehelper
+ </Export-Package>
+ </instructions>
+ </configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
import com.google.common.collect.ImmutableBiMap;
import java.net.InetAddress;
-import java.net.NetworkInterface;
import java.net.UnknownHostException;
import java.util.ArrayList;
-import java.util.Enumeration;
import java.util.List;
+import java.util.Map;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.ovsdb.southbound.SouthboundConstants;
import org.opendaylight.ovsdb.southbound.SouthboundMapper;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathTypeBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentationBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeName;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbFailModeBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentationBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.*;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeExternalIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeOtherConfigs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ProtocolEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfoBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIds;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIdsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIdsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Options;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.OptionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.OptionsKey;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final String DEFAULT_OPENFLOW_PORT = "6653";
private static final String OPENFLOW_CONNECTION_PROTOCOL = "tcp";
private MdsalUtils mdsalUtils;
+ public static final TopologyId OVSDB_TOPOLOGY_ID = new TopologyId(new Uri("ovsdb:1"));
public SouthboundUtils(MdsalUtils mdsalUtils) {
this.mdsalUtils = mdsalUtils;
}
+ public static final ImmutableBiMap<String, Class<? extends InterfaceTypeBase>> OVSDB_INTERFACE_TYPE_MAP
+ = new ImmutableBiMap.Builder<String, Class<? extends InterfaceTypeBase>>()
+ .put("internal", InterfaceTypeInternal.class)
+ .put("vxlan", InterfaceTypeVxlan.class)
+ .put("patch", InterfaceTypePatch.class)
+ .put("system", InterfaceTypeSystem.class)
+ .put("tap", InterfaceTypeTap.class)
+ .put("geneve", InterfaceTypeGeneve.class)
+ .put("gre", InterfaceTypeGre.class)
+ .put("ipsec_gre", InterfaceTypeIpsecGre.class)
+ .put("gre64", InterfaceTypeGre64.class)
+ .put("ipsec_gre64", InterfaceTypeIpsecGre64.class)
+ .put("lisp", InterfaceTypeLisp.class)
+ .put("dpdk", InterfaceTypeDpdk.class)
+ .put("dpdkr", InterfaceTypeDpdkr.class)
+ .put("dpdkvhost", InterfaceTypeDpdkvhost.class)
+ .put("dpdkvhostuser", InterfaceTypeDpdkvhostuser.class)
+ .build();
+
public NodeId createNodeId(IpAddress ip, PortNumber port) {
String uriString = SouthboundConstants.OVSDB_URI_PREFIX + "://"
+ new String(ip.getValue()) + ":" + port.getValue();
return SouthboundMapper.createInstanceIdentifier(createManagedNodeId(key, bridgeName));
}
+ public InstanceIdentifier<TerminationPoint> createTerminationPointInstanceIdentifier(Node node, String portName){
+
+ InstanceIdentifier<TerminationPoint> terminationPointPath = InstanceIdentifier
+ .create(NetworkTopology.class)
+ .child(Topology.class, new TopologyKey(OVSDB_TOPOLOGY_ID))
+ .child(Node.class,node.getKey())
+ .child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
+
+ LOG.debug("Termination point InstanceIdentifier generated : {}",terminationPointPath);
+ return terminationPointPath;
+ }
+
public NodeKey createNodeKey(IpAddress ip, PortNumber port) {
return new NodeKey(createNodeId(ip, port));
}
try {
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
} catch (InterruptedException e) {
- e.printStackTrace();
+ LOG.warn("Interrupted while waiting after adding OVSDB node {}", connectionInfoToString(connectionInfo), e);
}
return result;
}
public Node getOvsdbNode(final ConnectionInfo connectionInfo) {
- Node node = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL,
+ return mdsalUtils.read(LogicalDatastoreType.OPERATIONAL,
createInstanceIdentifier(connectionInfo));
- return node;
}
public boolean deleteOvsdbNode(final ConnectionInfo connectionInfo) {
try {
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
} catch (InterruptedException e) {
- e.printStackTrace();
+ LOG.warn("Interrupted while waiting after deleting OVSDB node {}", connectionInfoToString(connectionInfo),
+ e);
}
return result;
}
try {
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
} catch (InterruptedException e) {
- e.printStackTrace();
+ LOG.warn("Interrupted while waiting after deleting bridge {}", bridgeName, e);
}
return result;
}
* @throws InterruptedException
*/
public boolean addBridge(final ConnectionInfo connectionInfo, InstanceIdentifier<Node> bridgeIid,
- final String bridgeName, NodeId bridgeNodeId, final boolean setProtocolEntries,
- final Class<? extends OvsdbFailModeBase> failMode, final boolean setManagedBy,
- final Class<? extends DatapathTypeBase> dpType,
- final List<BridgeExternalIds> externalIds,
- final List<ControllerEntry> controllerEntries,
- final List<BridgeOtherConfigs> otherConfigs) throws InterruptedException {
+ final String bridgeName, NodeId bridgeNodeId, final boolean setProtocolEntries,
+ final Class<? extends OvsdbFailModeBase> failMode, final boolean setManagedBy,
+ final Class<? extends DatapathTypeBase> dpType,
+ final List<BridgeExternalIds> externalIds,
+ final List<ControllerEntry> controllerEntries,
+ final List<BridgeOtherConfigs> otherConfigs,
+ final String dpid) throws InterruptedException {
NodeBuilder bridgeNodeBuilder = new NodeBuilder();
if (bridgeIid == null) {
if (otherConfigs != null) {
ovsdbBridgeAugmentationBuilder.setBridgeOtherConfigs(otherConfigs);
}
+ if (dpid != null && !dpid.isEmpty()) {
+ DatapathId datapathId = new DatapathId(dpid);
+ ovsdbBridgeAugmentationBuilder.setDatapathId(datapathId);
+ }
bridgeNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, ovsdbBridgeAugmentationBuilder.build());
LOG.debug("Built with the intent to store bridge data {}",
ovsdbBridgeAugmentationBuilder.toString());
return result;
}
+ public boolean addBridge(final ConnectionInfo connectionInfo, InstanceIdentifier<Node> bridgeIid,
+ final String bridgeName, NodeId bridgeNodeId, final boolean setProtocolEntries,
+ final Class<? extends OvsdbFailModeBase> failMode, final boolean setManagedBy,
+ final Class<? extends DatapathTypeBase> dpType,
+ final List<BridgeExternalIds> externalIds,
+ final List<ControllerEntry> controllerEntries,
+ final List<BridgeOtherConfigs> otherConfigs) throws InterruptedException {
+ return addBridge(connectionInfo, bridgeIid, bridgeName, bridgeNodeId, setProtocolEntries,
+ failMode, setManagedBy, dpType, externalIds, controllerEntries,
+ otherConfigs, null);
+ }
+
+ public boolean addBridge(final ConnectionInfo connectionInfo, final String bridgeName)
+ throws InterruptedException {
+
+ return addBridge(connectionInfo, null, bridgeName, null, true,
+ SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"), true, null, null, null, null);
+ }
+
private void setManagedBy(final OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder,
final ConnectionInfo connectionInfo) {
InstanceIdentifier<Node> connectionNodePath = createInstanceIdentifier(connectionInfo);
ovsdbBridgeAugmentationBuilder.setManagedBy(new OvsdbNodeRef(connectionNodePath));
}
+
+ public Boolean addTerminationPoint(Node bridgeNode, String bridgeName, String portName,
+ String type, Map<String, String> options,
+ Map<String, String> externalIds) {
+ InstanceIdentifier<TerminationPoint> tpIid = createTerminationPointInstanceIdentifier(bridgeNode, portName);
+ OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
+
+ tpAugmentationBuilder.setName(portName);
+ if (type != null) {
+ tpAugmentationBuilder.setInterfaceType(OVSDB_INTERFACE_TYPE_MAP.get(type));
+ }
+
+ if (options != null && options.size() > 0) {
+ List<Options> optionsList = new ArrayList<>();
+ for (Map.Entry<String, String> entry : options.entrySet()) {
+ OptionsBuilder optionsBuilder = new OptionsBuilder();
+ optionsBuilder.setKey(new OptionsKey(entry.getKey()));
+ optionsBuilder.setOption(entry.getKey());
+ optionsBuilder.setValue(entry.getValue());
+ optionsList.add(optionsBuilder.build());
+ }
+ tpAugmentationBuilder.setOptions(optionsList);
+ }
+
+ if (externalIds != null && externalIds.size() > 0) {
+ List<InterfaceExternalIds> externalIdsList = new ArrayList<>();
+ for (Map.Entry<String, String> entry : externalIds.entrySet()) {
+ InterfaceExternalIdsBuilder interfaceExternalIdsBuilder = new InterfaceExternalIdsBuilder();
+ interfaceExternalIdsBuilder.setKey(new InterfaceExternalIdsKey(entry.getKey()));
+ interfaceExternalIdsBuilder.setExternalIdKey(entry.getKey());
+ interfaceExternalIdsBuilder.setExternalIdValue(entry.getValue());
+ externalIdsList.add(interfaceExternalIdsBuilder.build());
+ }
+ tpAugmentationBuilder.setInterfaceExternalIds(externalIdsList);
+ }
+
+ TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
+ tpBuilder.setKey(InstanceIdentifier.keyOf(tpIid));
+ tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
+ /* TODO SB_MIGRATION should this be merge or mdsalUtils.put */
+ return mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, tpIid, tpBuilder.build());
+ }
+
+ public TerminationPoint readTerminationPoint(Node bridgeNode, String bridgeName, String portName) {
+ InstanceIdentifier<TerminationPoint> tpIid = createTerminationPointInstanceIdentifier(
+ bridgeNode, portName);
+ return mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, tpIid);
+ }
+
+ public Boolean addTerminationPoint(Node bridgeNode, String bridgeName, String portName, String type) {
+ return addTerminationPoint(bridgeNode, bridgeName, portName, type, null, null);
+ }
+
+ public Boolean addTunnelTerminationPoint(Node bridgeNode, String bridgeName, String portName, String type,
+ Map<String, String> options) {
+ return addTerminationPoint(bridgeNode, bridgeName, portName, type, options, null);
+ }
}