From: Madhu Venugopal Date: Sun, 31 Aug 2014 03:52:14 +0000 (-0700) Subject: Changed the current WIP Pipeline Orchestrator to a more simplified Static Pipeline... X-Git-Tag: release/helium~92^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=a61aa88487a7da38c67e6e47a47bffc20e9a41ea;p=ovsdb.git Changed the current WIP Pipeline Orchestrator to a more simplified Static Pipeline that is easy to understand and debug than the dynamic pipeline management. Change-Id: Id53b7a814a433c450fd9780c0025f0f3e9ec9473 Signed-off-by: Madhu Venugopal --- diff --git a/openstack/net-virt-providers/pom.xml b/openstack/net-virt-providers/pom.xml index 8aacaec7b..b49fa1be0 100644 --- a/openstack/net-virt-providers/pom.xml +++ b/openstack/net-virt-providers/pom.xml @@ -65,6 +65,12 @@ utils.mdsal-openflow 1.0.0-SNAPSHOT + + junit + junit + compile + + diff --git a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/PipelineOrchestrator.java b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/PipelineOrchestrator.java deleted file mode 100644 index 47639dd94..000000000 --- a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/PipelineOrchestrator.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2014 Red Hat, Inc. - * - * 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 - * - * Authors : Dave Tucker - */ - -package org.opendaylight.ovsdb.openstack.netvirt.providers; - -import java.util.UUID; - -/** - * A PipelineOrchestrator provides the necessary orchestration logic to allow multiple network services - * to share a common OpenFlow 1.3 based multi-table pipeline. - */ -public interface PipelineOrchestrator { - - enum ServiceDirection { - UNDEFINED, - INGRESS, - EGRESS - } - - static final Integer PRE_NAT = 2; - static final Integer PRE_ACL = 7; - //ToDo: Add some sensible altitude constants - - /** - * Register a new service in the pipeline - * @param altitude an integer representing the desired placement in the pipeline where 0 = lowest. - * @param direction whether the service is ingress, egress - * @return a unique service identifier - */ - UUID registerService(Integer altitude, ServiceDirection direction); - - /** - * Unregister a service from the pipeline - * This clears any assigned table IDs and registers - */ - void unregisterService(UUID serviceID); - - /** - * Get the OpenFlow Table ID - * @param serviceID unique service identifier - */ - Integer getTableId(UUID serviceID); - - /** - * Assign an OVS Register to a service - * @return the integer value of the assigned register - */ - Integer assignRegister(UUID serviceID); - -} diff --git a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/PipelineOrchestratorImpl.java b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/PipelineOrchestratorImpl.java deleted file mode 100644 index a538e66c1..000000000 --- a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/PipelineOrchestratorImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.opendaylight.ovsdb.openstack.netvirt.providers; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Queues; - -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.UUID; - -/** - * Created by dave on 27/08/14. - */ -public class PipelineOrchestratorImpl implements PipelineOrchestrator { - - private Map serviceRegistry = Maps.newHashMap(); - private Queue registerQueue = Queues.newArrayBlockingQueue(16); - private List tableIdList = Lists.newArrayList(255); - - public UUID registerService(Integer altitude, ServiceDirection direction) { - return UUID.randomUUID(); - } - - @Override - public void unregisterService(UUID serviceID) { - ServiceProperties sp = serviceRegistry.get(serviceID); - List registers = sp.getRegisters(); - if (registers != null) { - for (Integer register : registers) { - registerQueue.add(register); - } - } - // Add Table ID allocation back - - } - - @Override - public Integer getTableId(UUID serviceID) { - ServiceProperties sp = serviceRegistry.get(serviceID); - return sp.tableId; - } - - @Override - public Integer assignRegister(UUID serviceID) { - Integer register = registerQueue.poll(); - if (register == null) { - throw new RuntimeException("No registers remaining"); - } - return register; - } - - private Integer assignTableId(Integer altitude) { - return null; - } - - private class ServiceProperties { - Integer altitude; - ServiceDirection direction; - Integer tableId; - List registers; - - public ServiceProperties(Integer altitude, - ServiceDirection direction, - Integer tableId, - List registers) { - this.altitude = altitude; - this.direction = direction; - this.tableId = tableId; - this.registers = registers; - } - - public Integer getAltitude() { - return altitude; - } - - public void setAltitude(Integer altitude) { - this.altitude = altitude; - } - - public ServiceDirection getDirection() { - return direction; - } - - public void setDirection(ServiceDirection direction) { - this.direction = direction; - } - - public Integer getTableId() { - return tableId; - } - - public void setTableId(Integer tableId) { - this.tableId = tableId; - } - - public List getRegisters() { - return registers; - } - - public void setRegisters(List registers) { - this.registers = registers; - } - - public void addRegister(Integer register) { - this.registers.add(register); - } - - } - -} diff --git a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/AbstractServiceInstance.java b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/AbstractServiceInstance.java new file mode 100644 index 000000000..3e6cf2365 --- /dev/null +++ b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/AbstractServiceInstance.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. + * + * 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 + * + * Authors : Madhu Venugopal + */ +package org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13; + +public abstract class AbstractServiceInstance { + Service service; + public AbstractServiceInstance (Service service) { + this.service = service; + } + + public int getTable() { + return service.getTable(); + } +} diff --git a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestrator.java b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestrator.java new file mode 100644 index 000000000..b64a88251 --- /dev/null +++ b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestrator.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. + * + * 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 + * + * Authors : Dave Tucker, Madhu Venugopal + */ + +package org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13; + +/** + * A PipelineOrchestrator provides the necessary orchestration logic to allow multiple network services + * to share a common OpenFlow 1.3 based multi-table pipeline. + */ +public interface PipelineOrchestrator { + void registerService(Service service, AbstractServiceInstance serviceInstance); + void unregisterService(Service service); + public Service getNextServiceInPipeline(Service service); + AbstractServiceInstance getServiceInstance(Service service); +} diff --git a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestratorImpl.java b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestratorImpl.java new file mode 100644 index 000000000..696601b1b --- /dev/null +++ b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestratorImpl.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. + * + * 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 + * + * Authors : Dave Tucker, Madhu Venugopal + */ + +package org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13; + +import java.util.List; +import java.util.Map; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +public class PipelineOrchestratorImpl implements PipelineOrchestrator { + + private List staticPipeline = Lists.newArrayList( + Service.CLASSIFIER, + Service.DIRECTOR, + Service.ARP_RESPONDER, + Service.INBOUND_NAT, + Service.INGRESS_ACL, + Service.LOAD_BALANCER, + Service.ROUTING, + Service.L2_REWRITE, + Service.L2_FORWARDING, + Service.EGRESS_ACL, + Service.OUTBOUND_NAT + ); + Map serviceRegistry = Maps.newConcurrentMap(); + + public PipelineOrchestratorImpl() { + } + @Override + public void registerService(Service service, + AbstractServiceInstance serviceInstance) { + serviceRegistry.put(service, serviceInstance); + } + + @Override + public void unregisterService(Service service) { + serviceRegistry.remove(service); + } + + @Override + public Service getNextServiceInPipeline(Service service) { + int index = staticPipeline.indexOf(service); + if (index >= staticPipeline.size() - 1) return null; + return staticPipeline.get(index + 1); + } + + @Override + public AbstractServiceInstance getServiceInstance(Service service) { + if (service == null) return null; + return serviceRegistry.get(service); + } +} diff --git a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/Service.java b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/Service.java new file mode 100644 index 000000000..ad4be89dc --- /dev/null +++ b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/Service.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. + * + * 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 + * + * Authors : Madhu Venugopal + */ + +package org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13; + +public enum Service { + + CLASSIFIER ((short) 0, "Classifier"), + DIRECTOR ((short) 10, "Director"), + ARP_RESPONDER ((short) 20, "Distributed ARP Responder"), + INBOUND_NAT ((short) 30, "DNAT for inbound floating-ip traffic"), + INGRESS_ACL ((short) 40, "Ingress Acces-control. Typically Openstack Egress Security group policies are applied here."), + LOAD_BALANCER ((short) 50, "Distributed LBaaS"), + ROUTING ((short) 60, "Distributed Virtual Routing (DVR)"), + L2_REWRITE ((short) 70, "Layer2 rewrite service"), + L2_FORWARDING ((short) 80, "Layer2 mac,vlan based forwarding"), + EGRESS_ACL ((short) 90, "Egress Acces-control.Typically Openstack Ingress Security group policies are applied here."), + OUTBOUND_NAT ((short) 100, "SNAT for traffic accessing external network"); + + short table; + String description; + + private Service (short table, String description) { + this.table = table; + this.description = description; + } + + public short getTable() { + return table; + } + + public String getDescription() { + return description; + } +} diff --git a/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestratorTest.java b/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestratorTest.java new file mode 100644 index 000000000..9707cdcfe --- /dev/null +++ b/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestratorTest.java @@ -0,0 +1,30 @@ +package org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Before; +import org.junit.Test; + +public class PipelineOrchestratorTest { + PipelineOrchestrator orchestrator; + @Before + public void initialize() { + orchestrator = new PipelineOrchestratorImpl(); + } + + @Test + public void testPipeline() { + assertEquals(orchestrator.getNextServiceInPipeline(Service.CLASSIFIER), Service.DIRECTOR); + assertEquals(orchestrator.getNextServiceInPipeline(Service.DIRECTOR), Service.ARP_RESPONDER); + assertEquals(orchestrator.getNextServiceInPipeline(Service.ARP_RESPONDER), Service.INBOUND_NAT); + assertEquals(orchestrator.getNextServiceInPipeline(Service.INBOUND_NAT), Service.INGRESS_ACL); + assertEquals(orchestrator.getNextServiceInPipeline(Service.INGRESS_ACL), Service.LOAD_BALANCER); + assertEquals(orchestrator.getNextServiceInPipeline(Service.LOAD_BALANCER), Service.ROUTING); + assertEquals(orchestrator.getNextServiceInPipeline(Service.ROUTING), Service.L2_REWRITE); + assertEquals(orchestrator.getNextServiceInPipeline(Service.L2_REWRITE), Service.L2_FORWARDING); + assertEquals(orchestrator.getNextServiceInPipeline(Service.L2_FORWARDING), Service.EGRESS_ACL); + assertEquals(orchestrator.getNextServiceInPipeline(Service.EGRESS_ACL), Service.OUTBOUND_NAT); + assertNull(orchestrator.getNextServiceInPipeline(Service.OUTBOUND_NAT)); + } +}