Changed the current WIP Pipeline Orchestrator to a more simplified Static Pipeline... 35/10535/1
authorMadhu Venugopal <mavenugo@gmail.com>
Sun, 31 Aug 2014 03:52:14 +0000 (20:52 -0700)
committerMadhu Venugopal <mavenugo@gmail.com>
Sun, 31 Aug 2014 03:52:14 +0000 (20:52 -0700)
Change-Id: Id53b7a814a433c450fd9780c0025f0f3e9ec9473
Signed-off-by: Madhu Venugopal <mavenugo@gmail.com>
openstack/net-virt-providers/pom.xml
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/PipelineOrchestrator.java [deleted file]
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/PipelineOrchestratorImpl.java [deleted file]
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/AbstractServiceInstance.java [new file with mode: 0644]
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestrator.java [new file with mode: 0644]
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestratorImpl.java [new file with mode: 0644]
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/Service.java [new file with mode: 0644]
openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestratorTest.java [new file with mode: 0644]

index 8aacaec7b96fb13255665e9554d46e0e1966c358..b49fa1be0935d0e2e96c90827a51f8fec3465b49 100644 (file)
           <artifactId>utils.mdsal-openflow</artifactId>
           <version>1.0.0-SNAPSHOT</version>
         </dependency>
+        <dependency>
+          <groupId>junit</groupId>
+          <artifactId>junit</artifactId>
+          <scope>compile</scope>
+        </dependency>
+
     </dependencies>
 
     <build>
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 (file)
index 47639dd..0000000
+++ /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 (file)
index a538e66..0000000
+++ /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<UUID, ServiceProperties> serviceRegistry = Maps.newHashMap();
-  private Queue<Integer> registerQueue = Queues.newArrayBlockingQueue(16);
-  private List<Integer> 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<Integer> 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<Integer> registers;
-
-    public ServiceProperties(Integer altitude,
-                             ServiceDirection direction,
-                             Integer tableId,
-                             List<Integer> 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<Integer> getRegisters() {
-      return registers;
-    }
-
-    public void setRegisters(List<Integer> 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 (file)
index 0000000..3e6cf23
--- /dev/null
@@ -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 (file)
index 0000000..b64a882
--- /dev/null
@@ -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 (file)
index 0000000..696601b
--- /dev/null
@@ -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<Service> 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<Service, AbstractServiceInstance> 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 (file)
index 0000000..ad4be89
--- /dev/null
@@ -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 (file)
index 0000000..9707cdc
--- /dev/null
@@ -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));
+    }
+}