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;
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;
PortSecurityHandler.class,
ProviderNetworkManagerImpl.class,
EventDispatcherImpl.class,
- FWaasHandler.class};
+ FWaasHandler.class,
+ LBaaSHandler.class};
return res;
}
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,
--- /dev/null
+/*
+ * 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;
+ }
+ }
+}
+
"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
+}