- Adding LBaaS handler skeleton to net-virt bundle, appropriate entries 26/10426/1
authorSrini Seetharaman <srini.seetharaman@gmail.com>
Thu, 28 Aug 2014 06:59:33 +0000 (23:59 -0700)
committerSrini Seetharaman <srini.seetharaman@gmail.com>
Thu, 28 Aug 2014 06:59:33 +0000 (23:59 -0700)
in AbstractEvent and Activator.

- Fixing Postman examples for LBaaS.

Change-Id: Id878ffe5bf1e8b1819a18f103b5ee9c4fe74e05e
Signed-off-by: Srini Seetharaman <srini.seetharaman@gmail.com>
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/AbstractEvent.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/Activator.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/LBaaSHandler.java [new file with mode: 0644]
resources/openstack/Neutron-v2.0-API-Examples.json.postman_collection

index 28b0afe63b8392e4439c420d9b30b5779e41cd10..7e78be94148a7b20d9cd20b87d29808521093282 100644 (file)
@@ -22,7 +22,8 @@ public abstract class AbstractEvent {
         NEUTRON_PORT_SECURITY,
         NEUTRON_ROUTER,
         NEUTRON_SUBNET,
-        NEUTRON_FWAAS;
+        NEUTRON_FWAAS,
+        NEUTRON_LBAAS;
 
         public static final int size = HandlerType.values().length;
     }
index f4992920cd4b39fe1a3ab8797c3e187620fcfa3a..1fb1ae05a65606548f792757534dee92db2e6082 100644 (file)
@@ -14,6 +14,9 @@ import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallAware;
 import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyAware;
 import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleAware;
 import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPAware;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerAware;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolAware;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolMemberAware;
 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronPortAware;
@@ -40,7 +43,6 @@ import org.opendaylight.ovsdb.openstack.netvirt.impl.VlanConfigurationCacheImpl;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
 import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener;
-
 import org.apache.felix.dm.Component;
 
 import java.util.Properties;
@@ -90,7 +92,8 @@ public class Activator extends ComponentActivatorAbstractBase {
                         PortSecurityHandler.class,
                         ProviderNetworkManagerImpl.class,
                         EventDispatcherImpl.class,
-                        FWaasHandler.class};
+                        FWaasHandler.class,
+                        LBaaSHandler.class};
         return res;
     }
 
@@ -224,6 +227,16 @@ public class Activator extends ComponentActivatorAbstractBase {
             c.add(createServiceDependency().setService(EventDispatcher.class).setRequired(true));
         }
 
+        if (imp.equals(LBaaSHandler.class)) {
+            Properties lbaasHandlerProperties = new Properties();
+            lbaasHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.NEUTRON_LBAAS);
+            c.setInterface(new String[] {INeutronLoadBalancerAware.class.getName(),
+                                         INeutronLoadBalancerPoolAware.class.getName(),
+                                         INeutronLoadBalancerPoolMemberAware.class.getName()},
+                                         lbaasHandlerProperties);
+            c.add(createServiceDependency().setService(EventDispatcher.class).setRequired(true));
+        }
+
         if (imp.equals(PortSecurityHandler.class)) {
             Properties portSecurityHandlerProperties = new Properties();
             portSecurityHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY,
diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/LBaaSHandler.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/LBaaSHandler.java
new file mode 100644 (file)
index 0000000..5bfea99
--- /dev/null
@@ -0,0 +1,207 @@
+/*
+ * Copyright (C) 2014 SDN Hub, LLC.
+ *
+ * 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 : Srini Seetharaman
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt;
+
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerAware;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolAware;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolMemberAware;
+import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancer;
+import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPool;
+import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPoolMember;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.HttpURLConnection;
+
+/**
+ * Handle requests for OpenStack Neutron v2.0 LBaaS API calls.
+ */
+
+//TODO: Implement INeutronLoadBalancerHealthMonitorAware, INeutronLoadBalancerListenerAware
+
+public class LBaaSHandler extends AbstractHandler
+        implements INeutronLoadBalancerAware, INeutronLoadBalancerPoolAware,
+            INeutronLoadBalancerPoolMemberAware {
+
+    static final Logger logger = LoggerFactory.getLogger(LBaaSHandler.class);
+
+    @Override
+    public int canCreateNeutronLoadBalancer(NeutronLoadBalancer neutronLoadBalancer) {
+        return HttpURLConnection.HTTP_CREATED;
+    }
+
+    @Override
+    public void neutronLoadBalancerCreated(NeutronLoadBalancer neutronLoadBalancer) {
+        logger.debug("Neutron LB Creation : {}", neutronLoadBalancer.toString());
+        //TODO: Trigger flowmod addition
+        int result = HttpURLConnection.HTTP_BAD_REQUEST;
+
+        result = canCreateNeutronLoadBalancer(neutronLoadBalancer);
+        if (result != HttpURLConnection.HTTP_CREATED) {
+            logger.debug("Neutron Load Balancer creation failed {} ", result);
+            return;
+        }
+    }
+
+    @Override
+    public int canUpdateNeutronLoadBalancer(NeutronLoadBalancer delta, NeutronLoadBalancer original) {
+        return HttpURLConnection.HTTP_OK;
+    }
+
+    @Override
+    public void neutronLoadBalancerUpdated(NeutronLoadBalancer neutronLoadBalancer) {
+        return;
+    }
+
+    @Override
+    public int canDeleteNeutronLoadBalancer(NeutronLoadBalancer neutronLoadBalancer) {
+        return HttpURLConnection.HTTP_OK;
+    }
+
+    @Override
+    public void neutronLoadBalancerDeleted(NeutronLoadBalancer neutronLoadBalancer) {
+        logger.debug("Neutron LB Deletion : {}", neutronLoadBalancer.toString());
+        //TODO: Trigger flowmod removals
+        int result = canDeleteNeutronLoadBalancer(neutronLoadBalancer);
+        if  (result != HttpURLConnection.HTTP_OK) {
+            logger.error(" delete Neutron NeutronLoadBalancer Pool validation failed for result - {} ", result);
+            return;
+        }
+    }
+
+    /**
+     * Invoked when a NeutronLoadBalancer Pools creation is requested
+     * to indicate if the specified Rule can be created.
+     *
+     * @param neutronLoadBalancerPool  An instance of proposed new Neutron LoadBalancer Pool object.
+     * @return A HTTP status code to the creation request.
+     */
+
+    @Override
+    public int canCreateNeutronLoadBalancerPool(NeutronLoadBalancerPool neutronLoadBalancerPool) {
+        return HttpURLConnection.HTTP_CREATED;
+    }
+
+    @Override
+    public void neutronLoadBalancerPoolCreated(NeutronLoadBalancerPool neutronLoadBalancerPool) {
+        logger.debug("Neutron LB Pool Creation : {}", neutronLoadBalancerPool.toString());
+        int result = HttpURLConnection.HTTP_BAD_REQUEST;
+
+        result = canCreateNeutronLoadBalancerPool(neutronLoadBalancerPool);
+        if (result != HttpURLConnection.HTTP_CREATED) {
+            logger.debug("Neutron Load Balancer creation failed {} ", result);
+            return;
+        }
+    }
+
+    @Override
+    public int canUpdateNeutronLoadBalancerPool(NeutronLoadBalancerPool delta, NeutronLoadBalancerPool original) {
+        return HttpURLConnection.HTTP_OK;
+    }
+
+    @Override
+    public void neutronLoadBalancerPoolUpdated(NeutronLoadBalancerPool neutronLoadBalancerPool) {
+        logger.debug("Neutron LB Pool updated : {}", neutronLoadBalancerPool.toString());
+        return;
+    }
+
+    @Override
+    public int canDeleteNeutronLoadBalancerPool(NeutronLoadBalancerPool neutronLoadBalancerPool) {
+        return HttpURLConnection.HTTP_OK;
+    }
+
+    @Override
+    public void neutronLoadBalancerPoolDeleted(NeutronLoadBalancerPool neutronLoadBalancerPool) {
+        logger.debug("Neutron LB Pool Deletion : {}", neutronLoadBalancerPool.toString());
+
+        int result = canDeleteNeutronLoadBalancerPool(neutronLoadBalancerPool);
+        if  (result != HttpURLConnection.HTTP_OK) {
+            logger.error(" delete Neutron NeutronLoadBalancer Pool validation failed for result - {} ", result);
+            return;
+        }
+    }
+    /**
+     * Invoked when a NeutronLoadBalancer Pool Members creation is requested
+     * to indicate if the specified Rule can be created.
+     *
+     * @param neutronLoadBalancerPoolMember  An instance of proposed new Neutron LoadBalancer Pool Member object.
+     * @return A HTTP status code to the creation request.
+     */
+
+    @Override
+    public int canCreateNeutronLoadBalancerPoolMember(NeutronLoadBalancerPoolMember neutronLoadBalancerPoolMember) {
+        return HttpURLConnection.HTTP_CREATED;
+    }
+
+    @Override
+    public void neutronLoadBalancerPoolMemberCreated(NeutronLoadBalancerPoolMember neutronLoadBalancerPoolMember) {
+        logger.debug("Neutron LB Pool Member Creation : {}", neutronLoadBalancerPoolMember.toString());
+
+        int result = HttpURLConnection.HTTP_BAD_REQUEST;
+
+        result = canCreateNeutronLoadBalancerPoolMember(neutronLoadBalancerPoolMember);
+        if (result != HttpURLConnection.HTTP_CREATED) {
+            logger.debug("Neutron Load Balancer creation failed {} ", result);
+            return;
+        }
+    }
+
+    @Override
+    public int canUpdateNeutronLoadBalancerPoolMember(NeutronLoadBalancerPoolMember delta, NeutronLoadBalancerPoolMember original) {
+        return HttpURLConnection.HTTP_OK;
+    }
+
+    @Override
+    public void neutronLoadBalancerPoolMemberUpdated(NeutronLoadBalancerPoolMember neutronLoadBalancerPoolMember) {
+        logger.debug("Neutron LB Pool Member updated : {}", neutronLoadBalancerPoolMember.toString());
+        return;
+    }
+
+    @Override
+    public int canDeleteNeutronLoadBalancerPoolMember(NeutronLoadBalancerPoolMember neutronLoadBalancerPoolMember) {
+        return HttpURLConnection.HTTP_OK;
+    }
+
+    @Override
+    public void neutronLoadBalancerPoolMemberDeleted(NeutronLoadBalancerPoolMember neutronLoadBalancerPoolMember) {
+        logger.debug("Neutron LB Pool Member Deletion : {}", neutronLoadBalancerPoolMember.toString());
+
+        int result = canDeleteNeutronLoadBalancerPoolMember(neutronLoadBalancerPoolMember);
+        if  (result != HttpURLConnection.HTTP_OK) {
+            logger.error(" delete Neutron NeutronLoadBalancer Pool Member validation failed for result - {} ", result);
+            return;
+        }
+    }
+
+    /**
+     * Process the event.
+     *
+     * @param abstractEvent the {@link org.opendaylight.ovsdb.openstack.netvirt.AbstractEvent} event to be handled.
+     * @see org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher
+     */
+    @Override
+    public void processEvent(AbstractEvent abstractEvent) {
+        if (!(abstractEvent instanceof NorthboundEvent)) {
+            logger.error("Unable to process abstract event " + abstractEvent);
+            return;
+        }
+        NorthboundEvent ev = (NorthboundEvent) abstractEvent;
+        switch (ev.getAction()) {
+            // TODO: add handling of events here, once callbacks do something
+            //       other than logging.
+            default:
+                logger.warn("Unable to process event action " + ev.getAction());
+                break;
+        }
+    }
+}
+
index 55c341fc007475bb101635954d3c4014dc3c66f8..b30e2004f764aa28789d4818716cadd45a9d8935 100644 (file)
                        "data": "{\n   \"healthmonitor\":{\n      \"id\":\"f3eeab00-8367-4524-b662-55e64d4cacb5\",\n      \"tenant_id\":\"453105b9-1754-413f-aab1-55f1af620750\",\n      \"type\":\"HTTP\",\n      \"delay\":20,\n      \"timeout\":10,\n      \"max_retries\":5,\n      \"http_method\":\"GET\",\n      \"url_path\":\"/check\",\n      \"expected_codes\":\"200-299\",\n      \"admin_state_up\":true,\n      \"status\":\"ACTIVE\"\n   }\n}",
                        "dataMode": "raw",
                        "name": "Post Add Neutron Load Balancer HealthMonitor",
-                       "description": "Example posting of a Neutron v2.0  Load Balancer Pool.",
+                       "description": "Example posting of a Neutron v2.0  Load Balancer HealthMonitor.",
                        "descriptionFormat": "html",
                        "time": 1407147940644,
                        "version": 2,
                {
                        "id": "0f889e0b-f37f-a82f-06b3-5db88c96f8f7",
                        "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
-                       "url": "http://127.0.0.1:8080/controller/nb/v2/neutron/fw/firewalls_rules",
+                       "url": "http://127.0.0.1:8080/controller/nb/v2/neutron/loadbalancers/",
                        "pathVariables": {},
                        "method": "GET",
                        "data": [],
                {
                        "id": "1fdc36bb-a2bd-23df-9ddf-b47fc9231d96",
                        "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
-                       "url": "http://127.0.0.1:8080/controller/nb/v2/neutron/fw/firewalls_rules",
+                       "url": "http://127.0.0.1:8080/controller/nb/v2/neutron/loadbalancers",
                        "pathVariables": {},
                        "method": "GET",
                        "data": [],
                        "responses": [],
                        "synced": false
                },
-               {
-                       "id": "2d935076-436b-4efa-5586-a7cbf8c385ab",
-                       "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
-                       "url": "http://127.0.0.1:8080/controller/nb/v2/neutron/fw/firewalls",
-                       "pathVariables": {},
-                       "method": "POST",
-                       "data": "{\n  \"firewall\": {\n    \"admin_state_up\": true,\n    \"description\": \"Example Neutron v2.0 Firewall Creation\",\n    \"firewall_policy_id\": \"c69933c1-b472-44f9-8226-30dc4ffd454c\",\n    \"id\": \"3b0ef8f4-82c7-44d4-a4fb-6177f9a21977\",\n    \"name\": \"Example FWaaS Firewall\",\n    \"status\": \"PENDING_CREATE\",\n    \"tenant_id\": \"45977fa2dbd7482098dd68d0d8970117\"\n  }\n}",
-                       "dataMode": "raw",
-                       "version": 2,
-                       "tests": "",
-                       "time": 1401140100321,
-                       "name": "Post Add Neutron Load Balancer",
-                       "description": "Example posting of a Neutron v2.0  Load Balancer (LBaaS).",
-                       "collectionId": "bd9b142f-e3ad-452d-f088-eed1b741b937",
-                       "responses": [],
-                       "synced": false
-               },
                {
                        "id": "36de75f0-4f3c-ca9e-adf5-155349f4b766",
                        "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
                        "synced": false
                }
        ]
-}
\ No newline at end of file
+}