import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Assert;
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;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.INeutronSecurityGroupCRUD;
-import org.opendaylight.neutron.spi.INeutronSecurityRuleCRUD;
-import org.opendaylight.neutron.spi.NeutronPort;
-import org.opendaylight.neutron.spi.NeutronSecurityGroup;
-import org.opendaylight.neutron.spi.NeutronSecurityRule;
-import org.opendaylight.neutron.spi.NeutronNetwork;
-import org.opendaylight.neutron.spi.NeutronSubnet;
+import org.opendaylight.netvirt.utils.netvirt.it.utils.NetvirtItUtils;
+import org.opendaylight.netvirt.utils.netvirt.it.utils.NeutronNetItUtil;
+import org.opendaylight.netvirt.utils.neutron.utils.NeutronUtils;
import org.opendaylight.ovsdb.lib.notation.Version;
import org.opendaylight.netvirt.openstack.netvirt.NetworkHandler;
import org.opendaylight.netvirt.openstack.netvirt.api.Southbound;
import org.opendaylight.netvirt.openstack.netvirt.providers.NetvirtProvidersProvider;
import org.opendaylight.netvirt.openstack.netvirt.providers.openflow13.PipelineOrchestrator;
import org.opendaylight.netvirt.openstack.netvirt.providers.openflow13.Service;
-import org.opendaylight.netvirt.utils.it.utils.ItUtils;
-import org.opendaylight.netvirt.utils.it.utils.NodeInfo;
-import org.opendaylight.netvirt.utils.mdsal.openflow.FlowUtils;
+import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityRule;
+import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSubnet;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityGroupCRUD;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
+import org.opendaylight.ovsdb.utils.ovsdb.it.utils.DockerOvs;
+import org.opendaylight.ovsdb.utils.ovsdb.it.utils.ItConstants;
+import org.opendaylight.ovsdb.utils.ovsdb.it.utils.OvsdbItUtils;
+import org.opendaylight.ovsdb.utils.ovsdb.it.utils.NodeInfo;
import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
public class NetvirtIT extends AbstractMdsalTestBase {
private static final Logger LOG = LoggerFactory.getLogger(NetvirtIT.class);
private static DataBroker dataBroker = null;
- private static ItUtils itUtils;
+ private static OvsdbItUtils itUtils;
+ private static NetvirtItUtils nvItUtils;
private static String addressStr;
private static String portStr;
private static String connectionType;
@Configuration
@Override
public Option[] config() {
- Option[] parentOptions = super.config();
- Option[] propertiesOptions = getPropertiesOptions();
+ Option[] ovsProps = super.config();
+ Option[] propertiesOptions = DockerOvs.getSysPropOptions();
Option[] otherOptions = getOtherOptions();
- Option[] options = new Option[parentOptions.length + propertiesOptions.length + otherOptions.length];
- System.arraycopy(parentOptions, 0, options, 0, parentOptions.length);
- System.arraycopy(propertiesOptions, 0, options, parentOptions.length, propertiesOptions.length);
- System.arraycopy(otherOptions, 0, options, parentOptions.length + propertiesOptions.length,
+ Option[] options = new Option[ovsProps.length + propertiesOptions.length + otherOptions.length];
+ System.arraycopy(ovsProps, 0, options, 0, ovsProps.length);
+ System.arraycopy(propertiesOptions, 0, options, ovsProps.length, propertiesOptions.length);
+ System.arraycopy(otherOptions, 0, options, ovsProps.length + propertiesOptions.length,
otherOptions.length);
return options;
}
};
}
- public Option[] getPropertiesOptions() {
- return new Option[] {
- propagateSystemProperties(NetvirtITConstants.SERVER_IPADDRESS,
- NetvirtITConstants.SERVER_PORT, NetvirtITConstants.CONNECTION_TYPE,
- NetvirtITConstants.CONTROLLER_IPADDRESS,
- NetvirtITConstants.USERSPACE_ENABLED)
- };
- }
-
@Override
public Option getLoggingOption() {
return composite(
LOG.info("setUp: Using the following properties: mode= {}, ip:port= {}:{}, controller ip: {}, " +
"userspace.enabled: {}",
connectionType, addressStr, portStr, controllerStr, userSpaceEnabled);
- if (connectionType.equalsIgnoreCase(NetvirtITConstants.CONNECTION_TYPE_ACTIVE)) {
- if (addressStr == null) {
- fail(usage());
- }
- }
}
@Before
getProperties();
- if (connectionType.equalsIgnoreCase(NetvirtITConstants.CONNECTION_TYPE_ACTIVE)) {
- if (addressStr == null) {
- fail(usage());
- }
- }
-
- dataBroker = getDatabroker(getProviderContext());
- itUtils = new ItUtils(dataBroker);
+ dataBroker = NetvirtItUtils.getDatabroker(getProviderContext());
+ itUtils = new OvsdbItUtils(dataBroker);
+ nvItUtils = new NetvirtItUtils(dataBroker);
mdsalUtils = new MdsalUtils(dataBroker);
assertNotNull("mdsalUtils should not be null", mdsalUtils);
assertTrue("Did not find " + NETVIRT_TOPOLOGY_ID, getNetvirtTopology());
return providerContext;
}
- private DataBroker getDatabroker(BindingAwareBroker.ProviderContext providerContext) {
- DataBroker dataBroker = providerContext.getSALService(DataBroker.class);
- assertNotNull("dataBroker should not be null", dataBroker);
- return dataBroker;
- }
-
private Boolean getNetvirtTopology() {
LOG.info("getNetvirtTopology: looking for {}...", NETVIRT_TOPOLOGY_ID);
Boolean found = false;
staticPipelineFound.add(service);
}
String flowId = "DEFAULT_PIPELINE_FLOW_" + pipelineOrchestrator.getTable(service);
- verifyFlow(datapathId, flowId, service);
+ nvItUtils.verifyFlow(datapathId, flowId, pipelineOrchestrator.getTable(service));
}
assertEquals("did not find all expected flows in static pipeline",
staticPipeline.size(), staticPipelineFound.size());
String flowId = "TableOffset_" + pipelineOrchestrator.getTable(Service.CLASSIFIER);
- verifyFlow(datapathId, flowId, Service.CLASSIFIER.getTable());
+ nvItUtils.verifyFlow(datapathId, flowId, Service.CLASSIFIER.getTable());
Assert.assertTrue(southboundUtils.deleteBridge(connectionInfo, NetvirtITConstants.INTEGRATION_BRIDGE_NAME));
Thread.sleep(1000);
@Test
public void testNetVirt() throws InterruptedException {
LOG.info("testNetVirt: starting test");
- ConnectionInfo connectionInfo = SouthboundUtils.getConnectionInfo(addressStr, portStr);
- NodeInfo nodeInfo = itUtils.createNodeInfo(connectionInfo, null);
- nodeInfo.connect();
- LOG.info("testNetVirt: should be connected: {}", nodeInfo.ovsdbNode.getNodeId());
-
- List<Service> staticPipeline = pipelineOrchestrator.getStaticPipeline();
- List<Service> staticPipelineFound = Lists.newArrayList();
- for (Service service : pipelineOrchestrator.getServiceRegistry().keySet()) {
- if (staticPipeline.contains(service)) {
- staticPipelineFound.add(service);
+ try(DockerOvs ovs = new DockerOvs()) {
+ ConnectionInfo connectionInfo = SouthboundUtils.getConnectionInfo(ovs.getOvsdbAddress(0), ovs.getOvsdbPort(0));
+ NodeInfo nodeInfo = itUtils.createNodeInfo(connectionInfo, null);
+ nodeInfo.connect();
+ LOG.info("testNetVirt: should be connected: {}", nodeInfo.ovsdbNode.getNodeId());
+
+ List<Service> staticPipeline = pipelineOrchestrator.getStaticPipeline();
+ List<Service> staticPipelineFound = Lists.newArrayList();
+ for (Service service : pipelineOrchestrator.getServiceRegistry().keySet()) {
+ if (staticPipeline.contains(service)) {
+ staticPipelineFound.add(service);
+ }
+ String flowId = "DEFAULT_PIPELINE_FLOW_" + pipelineOrchestrator.getTable(service);
+ nvItUtils.verifyFlow(nodeInfo.datapathId, flowId, pipelineOrchestrator.getTable(service));
}
- String flowId = "DEFAULT_PIPELINE_FLOW_" + pipelineOrchestrator.getTable(service);
- verifyFlow(nodeInfo.datapathId, flowId, service);
- }
- assertEquals("did not find all expected flows in static pipeline",
- staticPipeline.size(), staticPipelineFound.size());
+ assertEquals("did not find all expected flows in static pipeline",
+ staticPipeline.size(), staticPipelineFound.size());
- southboundUtils.addTerminationPoint(nodeInfo.bridgeNode, NetvirtITConstants.PORT_NAME, "internal", null, null, 0L);
- Thread.sleep(1000);
- OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
- southbound.getTerminationPointOfBridge(nodeInfo.bridgeNode, NetvirtITConstants.PORT_NAME);
- Assert.assertNotNull("Did not find " + NetvirtITConstants.PORT_NAME, ovsdbTerminationPointAugmentation);
+ southboundUtils.addTerminationPoint(nodeInfo.bridgeNode, NetvirtITConstants.PORT_NAME, "internal", null, null, 0L);
+ Thread.sleep(1000);
+ OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
+ southbound.getTerminationPointOfBridge(nodeInfo.bridgeNode, NetvirtITConstants.PORT_NAME);
+ Assert.assertNotNull("Did not find " + NetvirtITConstants.PORT_NAME, ovsdbTerminationPointAugmentation);
- nodeInfo.disconnect();
+ nodeInfo.disconnect();
+ } catch (Exception e) {
+ LOG.warn("testNetVirt: Exception thrown by OvsDocker.OvsDocker()", e);
+ }
}
@Test
final String portId = "521e29d6-67b8-4b3c-8633-027d21195113";
final String dhcpPortId ="521e29d6-67b8-4b3c-8633-027d21195115";
- ConnectionInfo connectionInfo = SouthboundUtils.getConnectionInfo(addressStr, portStr);
- NodeInfo nodeInfo = itUtils.createNodeInfo(connectionInfo, null);
- nodeInfo.connect();
- LOG.info("testNetVirtFixedSG: should be connected: {}", nodeInfo.ovsdbNode.getNodeId());
+ try(DockerOvs ovs = new DockerOvs()) {
+ ConnectionInfo connectionInfo = SouthboundUtils.getConnectionInfo(ovs.getOvsdbAddress(0), ovs.getOvsdbPort(0));
+ NodeInfo nodeInfo = itUtils.createNodeInfo(connectionInfo, null);
+ nodeInfo.connect();
+ LOG.info("testNetVirtFixedSG: should be connected: {}", nodeInfo.ovsdbNode.getNodeId());
+
+ //TBD: This should be a utility function
+ // Verify the minimum version required for this test
+ OvsdbNodeAugmentation ovsdbNodeAugmentation = nodeInfo.ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
+ Assert.assertNotNull(ovsdbNodeAugmentation);
+ assertNotNull(ovsdbNodeAugmentation.getOvsVersion());
+ String ovsVersion = ovsdbNodeAugmentation.getOvsVersion();
+ Version version = Version.fromString(ovsVersion);
+ if (version.compareTo(minSGOvsVersion) < 0) {
+ LOG.warn("{} minimum version is required", minSGOvsVersion);
+ Assert.assertTrue(southboundUtils.deleteBridge(connectionInfo,
+ NetvirtITConstants.INTEGRATION_BRIDGE_NAME));
+ Thread.sleep(1000);
+ Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
+ return;
+ }
- // Verify the minimum version required for this test
- OvsdbNodeAugmentation ovsdbNodeAugmentation = nodeInfo.ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
- Assert.assertNotNull(ovsdbNodeAugmentation);
- assertNotNull(ovsdbNodeAugmentation.getOvsVersion());
- String ovsVersion = ovsdbNodeAugmentation.getOvsVersion();
- Version version = Version.fromString(ovsVersion);
- if (version.compareTo(minSGOvsVersion) < 0) {
- LOG.warn("{} minimum version is required", minSGOvsVersion);
- Assert.assertTrue(southboundUtils.deleteBridge(connectionInfo,
- NetvirtITConstants.INTEGRATION_BRIDGE_NAME));
- Thread.sleep(1000);
- Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
- return;
- }
+ //TBD: Use NeutronNetItUtil
+ NeutronNetwork nn = neutronUtils.createNeutronNetwork(networkId, tenantId,
+ NetworkHandler.NETWORK_TYPE_VXLAN, "100");
+ NeutronSubnet ns = neutronUtils.createNeutronSubnet(subnetId, tenantId, networkId, "10.0.0.0/24");
+ NeutronPort nport = neutronUtils.createNeutronPort(networkId, subnetId, portId,
+ "compute", "10.0.0.10", "f6:00:00:0f:00:01");
+ NeutronPort dhcp = neutronUtils.createNeutronPort(networkId, subnetId, dhcpPortId,
+ "dhcp", "10.0.0.1", "f6:00:00:0f:00:02");
- NeutronNetwork nn = neutronUtils.createNeutronNetwork(networkId, tenantId,
- NetworkHandler.NETWORK_TYPE_VXLAN, "100");
- NeutronSubnet ns = neutronUtils.createNeutronSubnet(subnetId, tenantId, networkId, "10.0.0.0/24");
- NeutronPort nport = neutronUtils.createNeutronPort(networkId, subnetId, portId,
- "compute", "10.0.0.10", "f6:00:00:0f:00:01");
- NeutronPort dhcp = neutronUtils.createNeutronPort(networkId, subnetId, dhcpPortId,
- "dhcp", "10.0.0.1", "f6:00:00:0f:00:02");
+ Thread.sleep(1000);
+ Map<String, String> externalIds = Maps.newHashMap();
+ externalIds.put("attached-mac", "f6:00:00:0f:00:01");
+ externalIds.put("iface-id", portId);
+ southboundUtils.addTerminationPoint(nodeInfo.bridgeNode, portName, "internal", null, externalIds, 3L);
+ southboundUtils.addTerminationPoint(nodeInfo.bridgeNode, "vm1", "internal", null, null, 0L);
+ southboundUtils.addTerminationPoint(nodeInfo.bridgeNode, "vm2", "internal", null, null, 0L);
+ Map<String, String> options = Maps.newHashMap();
+ options.put("key", "flow");
+ options.put("remote_ip", "192.168.120.32");
+ southboundUtils.addTerminationPoint(nodeInfo.bridgeNode, "vx", "vxlan", options, null, 4L);
+ Thread.sleep(1000);
- Thread.sleep(1000);
- Map<String, String> externalIds = Maps.newHashMap();
- externalIds.put("attached-mac", "f6:00:00:0f:00:01");
- externalIds.put("iface-id", portId);
- southboundUtils.addTerminationPoint(nodeInfo.bridgeNode, portName, "internal", null, externalIds, 3L);
- southboundUtils.addTerminationPoint(nodeInfo.bridgeNode, "vm1", "internal", null, null, 0L);
- southboundUtils.addTerminationPoint(nodeInfo.bridgeNode, "vm2", "internal", null, null, 0L);
- Map<String, String> options = Maps.newHashMap();
- options.put("key", "flow");
- options.put("remote_ip", "192.168.120.32");
- southboundUtils.addTerminationPoint(nodeInfo.bridgeNode, "vx", "vxlan", options, null, 4L);
- Thread.sleep(1000);
+ String flowId = "Egress_DHCP_Client" + "_Permit_";
+ nvItUtils.verifyFlow(nodeInfo.datapathId, flowId, pipelineOrchestrator.getTable(Service.EGRESS_ACL));
- String flowId = "Egress_DHCP_Client" + "_Permit_";
- verifyFlow(nodeInfo.datapathId, flowId, Service.EGRESS_ACL);
+ testDefaultSG(nport, nodeInfo.datapathId, nn, tenantId, portId);
+ Thread.sleep(1000);
- testDefaultSG(nport, nodeInfo.datapathId, nn, tenantId, portId);
- Thread.sleep(1000);
+ assertTrue(neutronUtils.removeNeutronPort(dhcp.getID()));
+ assertTrue(neutronUtils.removeNeutronPort(nport.getID()));
+ assertTrue(neutronUtils.removeNeutronSubnet(ns.getID()));
+ assertTrue(neutronUtils.removeNeutronNetwork(nn.getID()));
- nodeInfo.disconnect();
+ nodeInfo.disconnect();
+ } catch (Exception e) {
+ LOG.warn("testNetVirtFixedSG: Exception thrown by OvsDocker.OvsDocker()", e);
+ }
}
private void testDefaultSG(NeutronPort nport, long datapathId, NeutronNetwork nn, String tenantId, String portId)
assertNotNull("Could not find ineutronSecurityRuleCRUD Service", ineutronSecurityRuleCRUD);
NeutronSecurityGroup neutronSG = new NeutronSecurityGroup();
- neutronSG.setSecurityGroupDescription("testig defaultSG-IT");
neutronSG.setSecurityGroupName("DefaultSG");
- neutronSG.setSecurityGroupUUID("d3329053-bae5-4bf4-a2d1-7330f11ba5db");
- neutronSG.setTenantID(tenantId);
+ neutronSG.setID("d3329053-bae5-4bf4-a2d1-7330f11ba5db");
+ neutronSG.setSecurityGroupTenantID(tenantId);
List<NeutronSecurityRule> nsrs = new ArrayList<>();
NeutronSecurityRule nsrIN = new NeutronSecurityRule();
nsrIN.setSecurityRuleGroupID("d3329053-bae5-4bf4-a2d1-7330f11ba5db");
nsrIN.setSecurityRuleProtocol("TCP");
nsrIN.setSecurityRuleRemoteIpPrefix("10.0.0.0/24");
- nsrIN.setSecurityRuleUUID("823faaf7-175d-4f01-a271-0bf56fb1e7e6");
- nsrIN.setTenantID(tenantId);
+ nsrIN.setID("823faaf7-175d-4f01-a271-0bf56fb1e7e6");
+ nsrIN.setSecurityRuleTenantID(tenantId);
NeutronSecurityRule nsrEG = new NeutronSecurityRule();
nsrEG.setSecurityRemoteGroupID(null);
nsrEG.setSecurityRuleGroupID("d3329053-bae5-4bf4-a2d1-7330f11ba5db");
nsrEG.setSecurityRuleProtocol("TCP");
nsrEG.setSecurityRuleRemoteIpPrefix("10.0.0.0/24");
- nsrEG.setSecurityRuleUUID("823faaf7-175d-4f01-a271-0bf56fb1e7e1");
- nsrEG.setTenantID(tenantId);
+ nsrEG.setID("823faaf7-175d-4f01-a271-0bf56fb1e7e1");
+ nsrEG.setSecurityRuleTenantID(tenantId);
nsrs.add(nsrIN);
nsrs.add(nsrEG);
- neutronSG.setSecurityRules(nsrs);
ineutronSecurityRuleCRUD.addNeutronSecurityRule(nsrIN);
ineutronSecurityRuleCRUD.addNeutronSecurityRule(nsrEG);
- ineutronSecurityGroupCRUD.add(neutronSG);
+ ineutronSecurityGroupCRUD.addNeutronSecurityGroup(neutronSG);
List<NeutronSecurityGroup> sgs = new ArrayList<>();
sgs.add(neutronSG);
INeutronPortCRUD iNeutronPortCRUD =
(INeutronPortCRUD) ServiceHelper.getGlobalInstance(INeutronPortCRUD.class, this);
- iNeutronPortCRUD.update(portId, nport);
+ iNeutronPortCRUD.updatePort(portId, nport);
LOG.info("Neutron ports have been added");
Thread.sleep(10000);
String flowId = "Egress_IP" + nn.getProviderSegmentationID() + "_" + nport.getMacAddress() + "_Permit_";
- verifyFlow(datapathId, flowId, Service.EGRESS_ACL);
+ nvItUtils.verifyFlow(datapathId, flowId, pipelineOrchestrator.getTable(Service.EGRESS_ACL));
flowId = "Ingress_IP" + nn.getProviderSegmentationID() + "_" + nport.getMacAddress() + "_Permit_";
- verifyFlow(datapathId, flowId, Service.INGRESS_ACL);
+ nvItUtils.verifyFlow(datapathId, flowId, pipelineOrchestrator.getTable(Service.INGRESS_ACL));
+
+ ineutronSecurityGroupCRUD.removeNeutronSecurityGroup(neutronSG.getID());
+ ineutronSecurityRuleCRUD.removeNeutronSecurityRule(nsrEG.getID());
+ ineutronSecurityRuleCRUD.removeNeutronSecurityRule(nsrIN.getID());
}
- 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++) {
- LOG.info("getFlow try {} from {}: looking for flow: {}, node: {}",
- i, store, flowBuilder.build(), nodeBuilder.build());
- flow = FlowUtils.getFlow(flowBuilder, nodeBuilder, dataBroker.newReadOnlyTransaction(), store);
- if (flow != null) {
- LOG.info("getFlow try {} from {}: found flow: {}", i, store, flow);
- break;
+ /**
+ * Test a basic neutron use case. This test constructs a Neutron network, subnet, dhcp port, and two "vm" ports
+ * and validates that the correct flows are installed on OVS.
+ * @throws InterruptedException if we're interrupted while waiting for some mdsal operation to complete
+ */
+ @Test
+ public void testNeutronNet() throws InterruptedException {
+ LOG.warn("testNeutronNet: starting test");
+ try(DockerOvs ovs = new DockerOvs()) {
+ ConnectionInfo connectionInfo = SouthboundUtils.getConnectionInfo(ovs.getOvsdbAddress(0), ovs.getOvsdbPort(0));
+ NodeInfo nodeInfo = itUtils.createNodeInfo(connectionInfo, null);
+ nodeInfo.connect();
+ LOG.warn("testNeutronNet: should be connected: {}", nodeInfo.ovsdbNode.getNodeId());
+
+ // Create the objects
+ NeutronNetItUtil net = new NeutronNetItUtil(southboundUtils, UUID.randomUUID().toString());
+ net.create();
+ net.createPort(nodeInfo.bridgeNode, "dhcp", "network:dhcp");
+ net.createPort(nodeInfo.bridgeNode, "vm1");
+ net.createPort(nodeInfo.bridgeNode, "vm2");
+
+
+ // Check flows created for all ports
+ for (int i = 1; i <= net.neutronPorts.size(); i++) {
+ nvItUtils.verifyFlow(nodeInfo.datapathId, "DropFilter_" + i,
+ pipelineOrchestrator.getTable(Service.CLASSIFIER));
+ nvItUtils.verifyFlow(nodeInfo.datapathId, "LocalMac_" + net.segId + "_" + i + "_" + net.macFor(i),
+ pipelineOrchestrator.getTable(Service.CLASSIFIER));
+ nvItUtils.verifyFlow(nodeInfo.datapathId, "ArpResponder_" + net.segId + "_" + net.ipFor(i),
+ pipelineOrchestrator.getTable(Service.ARP_RESPONDER));
+ nvItUtils.verifyFlow(nodeInfo.datapathId, "UcastOut_" + net.segId + "_" + i + "_" + net.macFor(i),
+ pipelineOrchestrator.getTable(Service.L2_FORWARDING));
}
- Thread.sleep(1000);
+
+ // Check flows created for vm ports only
+ for (int i = 2; i <= net.neutronPorts.size(); i++) {
+ nvItUtils.verifyFlow(nodeInfo.datapathId, "Ingress_ARP_" + net.segId + "_" + i + "_",
+ pipelineOrchestrator.getTable(Service.INGRESS_ACL));
+
+ nvItUtils.verifyFlow(nodeInfo.datapathId, "Egress_Allow_VM_IP_MAC_" + i + net.macFor(i) + "_Permit_",
+ pipelineOrchestrator.getTable(Service.EGRESS_ACL));
+ nvItUtils.verifyFlow(nodeInfo.datapathId, "Egress_ARP_" + net.segId + "_" + i + "_",
+ pipelineOrchestrator.getTable(Service.EGRESS_ACL));
+ nvItUtils.verifyFlow(nodeInfo.datapathId, "Egress_DHCP_Server_" + i + "_DROP_",
+ pipelineOrchestrator.getTable(Service.EGRESS_ACL));
+ nvItUtils.verifyFlow(nodeInfo.datapathId, "Egress_DHCPv6_Server_" + i + "_DROP_",
+ pipelineOrchestrator.getTable(Service.EGRESS_ACL));
+ }
+
+ // Check ingress/egress acl flows for DHCP
+ nvItUtils.verifyFlow(nodeInfo.datapathId, "Egress_DHCP_Client_Permit_",
+ pipelineOrchestrator.getTable(Service.EGRESS_ACL));
+ nvItUtils.verifyFlow(nodeInfo.datapathId, "Egress_DHCPv6_Client_Permit_",
+ pipelineOrchestrator.getTable(Service.EGRESS_ACL));
+ nvItUtils.verifyFlow(nodeInfo.datapathId, "Ingress_DHCPv6_Server" + net.segId + "_"
+ + net.macFor(1) + "_Permit_", pipelineOrchestrator.getTable(Service.INGRESS_ACL));
+ nvItUtils.verifyFlow(nodeInfo.datapathId, "Ingress_DHCP_Server" + net.segId + "_"
+ + net.macFor(1) + "_Permit_", pipelineOrchestrator.getTable(Service.INGRESS_ACL));
+
+ // Check l2 broadcast flows
+ nvItUtils.verifyFlow(nodeInfo.datapathId, "TunnelFloodOut_" + net.segId,
+ pipelineOrchestrator.getTable(Service.L2_FORWARDING));
+ nvItUtils.verifyFlow(nodeInfo.datapathId, "BcastOut_" + net.segId,
+ pipelineOrchestrator.getTable(Service.L2_FORWARDING));
+
+ //TBD Figure out why this does not work:
+ //nvItUtils.verifyFlow(nodeInfo.datapathId, "TunnelMiss_" + net.segId,
+ // pipelineOrchestrator.getTable(Service.L2_FORWARDING));
+
+ net.destroy();
+ nodeInfo.disconnect();
+ } catch (Exception e) {
+ LOG.warn("testNeutronNet: Exception thrown by OvsDocker.OvsDocker()", e);
}
- return flow;
}
- private void verifyFlow(long datapathId, String flowId, short table) throws InterruptedException {
- org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder nodeBuilder =
- FlowUtils.createNodeBuilder(datapathId);
- FlowBuilder flowBuilder =
- FlowUtils.initFlowBuilder(new FlowBuilder(), flowId, table);
- Flow flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.CONFIGURATION);
- assertNotNull("Could not find flow in config: " + flowBuilder.build() + "--" + nodeBuilder.build(), flow);
- flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.OPERATIONAL);
- assertNotNull("Could not find flow in operational: " + flowBuilder.build() + "--" + nodeBuilder.build(),
- flow);
+ @Test
+ public void twoNodes() throws InterruptedException {
+
+ System.getProperties().setProperty(ItConstants.DOCKER_COMPOSE_FILE_NAME, "two_dockers-ovs-2.5.1.yml");
+ try(DockerOvs ovs = new DockerOvs()) {
+ ConnectionInfo connectionInfo = SouthboundUtils.getConnectionInfo(ovs.getOvsdbAddress(0), ovs.getOvsdbPort(0));
+ NodeInfo nodeInfo0 = itUtils.createNodeInfo(connectionInfo, null);
+ nodeInfo0.connect();
+ LOG.warn("testTwoNodes: should be connected: {}", nodeInfo0.ovsdbNode.getNodeId());
+ connectionInfo = SouthboundUtils.getConnectionInfo(ovs.getOvsdbAddress(1), ovs.getOvsdbPort(1));
+ NodeInfo nodeInfo1 = itUtils.createNodeInfo(connectionInfo, null);
+ nodeInfo1.connect();
+ LOG.warn("testTwoNodes: should be connected: {}", nodeInfo1.ovsdbNode.getNodeId());
+
+ nodeInfo0.disconnect();
+ nodeInfo1.disconnect();
+ } catch (Exception e) {
+ LOG.warn("testTwoNodes: Exception thrown by OvsDocker.OvsDocker()", e);
+ }
}
- private void verifyFlow(long datapathId, String flowId, Service service) throws InterruptedException {
- verifyFlow(datapathId, flowId, pipelineOrchestrator.getTable(service));
- }
}