Merge "NXM_NX_NSP openflow extended match support."
[ovsdb.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / RouterHandler.java
1 /*
2  * Copyright (C) 2013 Red Hat, Inc.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Authors : Dave Tucker, Flavio Fernandes
9  */
10 package org.opendaylight.ovsdb.openstack.netvirt;
11
12 import org.opendaylight.controller.networkconfig.neutron.INeutronRouterAware;
13 import org.opendaylight.controller.networkconfig.neutron.NeutronRouter;
14 import org.opendaylight.controller.networkconfig.neutron.NeutronRouter_Interface;
15 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
16 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
17 import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener;
18
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 import java.net.HttpURLConnection;
23
24 /**
25  * Handle requests for Neutron Router.
26  */
27 public class RouterHandler extends AbstractHandler
28         implements INeutronRouterAware {
29
30     /**
31      * Logger instance.
32      */
33     static final Logger logger = LoggerFactory.getLogger(RouterHandler.class);
34
35     private volatile OvsdbConfigurationService ovsdbConfigurationService;
36     private volatile OvsdbConnectionService connectionService;
37     private volatile OvsdbInventoryListener ovsdbInventoryListener;
38
39     /**
40      * Services provide this interface method to indicate if the specified router can be created
41      *
42      * @param router
43      *            instance of proposed new Neutron Router object
44      * @return integer
45      *            the return value is understood to be a HTTP status code.  A return value outside of 200 through 299
46      *            results in the create operation being interrupted and the returned status value reflected in the
47      *            HTTP response.
48      */
49     @Override
50     public int canCreateRouter(NeutronRouter router) {
51         return HttpURLConnection.HTTP_OK;
52     }
53
54     /**
55      * Services provide this interface method for taking action after a router has been created
56      *
57      * @param router
58      *            instance of new Neutron Router object
59      */
60     @Override
61     public void neutronRouterCreated(NeutronRouter router) {
62         logger.debug(" Router created {}, uuid {}", router.getName(), router.getRouterUUID());
63     }
64
65     /**
66      * Services provide this interface method to indicate if the specified router can be changed using the specified
67      * delta
68      *
69      * @param delta
70      *            updates to the router object using patch semantics
71      * @param router
72      *            instance of the Neutron Router object to be updated
73      * @return integer
74      *            the return value is understood to be a HTTP status code.  A return value outside of 200 through 299
75      *            results in the update operation being interrupted and the returned status value reflected in the
76      *            HTTP response.
77      */
78     @Override
79     public int canUpdateRouter(NeutronRouter delta, NeutronRouter original) {
80         return HttpURLConnection.HTTP_OK;
81     }
82
83     /**
84      * Services provide this interface method for taking action after a router has been updated
85      *
86      * @param router
87      *            instance of modified Neutron Router object
88      */
89     @Override
90     public void neutronRouterUpdated(NeutronRouter router) {
91         logger.debug(" Router updated {}", router.getName());
92     }
93
94     /**
95      * Services provide this interface method to indicate if the specified router can be deleted
96      *
97      * @param router
98      *            instance of the Neutron Router object to be deleted
99      * @return integer
100      *            the return value is understood to be a HTTP status code.  A return value outside of 200 through 299
101      *            results in the delete operation being interrupted and the returned status value reflected in the
102      *            HTTP response.
103      */
104     @Override
105     public int canDeleteRouter(NeutronRouter router) {
106         return HttpURLConnection.HTTP_OK;
107     }
108
109     /**
110      * Services provide this interface method for taking action after a router has been deleted
111      *
112      * @param router
113      *            instance of deleted Router Network object
114      */
115     @Override
116     public void neutronRouterDeleted(NeutronRouter router) {
117         logger.debug(" Router deleted {}, uuid {}", router.getName(), router.getRouterUUID());
118     }
119
120     /**
121      * Services provide this interface method to indicate if the specified interface can be attached to the specified
122      * route
123      *
124      * @param router
125      *            instance of the base Neutron Router object
126      * @param routerInterface
127      *            instance of the NeutronRouter_Interface to be attached to the router
128      * @return integer
129      *            the return value is understood to be a HTTP status code.  A return value outside of 200 through 299
130      *            results in the attach operation being interrupted and the returned status value reflected in the
131      *            HTTP response.
132      */
133     @Override
134     public int canAttachInterface(NeutronRouter router, NeutronRouter_Interface routerInterface) {
135         logger.debug(" Router {} asked if it can attach interface {}. Subnet {}",
136                      router.getName(),
137                      routerInterface.getPortUUID(),
138                      routerInterface.getSubnetUUID());
139         return HttpURLConnection.HTTP_OK;
140     }
141
142     /**
143      * Services provide this interface method for taking action after an interface has been added to a router
144      *
145      * @param router
146      *            instance of the base Neutron Router object
147      * @param routerInterface
148      *            instance of the NeutronRouter_Interface being attached to the router
149      */
150     @Override
151     public void neutronRouterInterfaceAttached(NeutronRouter router, NeutronRouter_Interface routerInterface) {
152         logger.debug(" Router {} interface {} attached. Subnet {}", router.getName(), routerInterface.getPortUUID(),
153                      routerInterface.getSubnetUUID());
154     }
155
156     /**
157      * Services provide this interface method to indicate if the specified interface can be detached from the specified
158      * router
159      *
160      * @param router
161      *            instance of the base Neutron Router object
162      * @param routerInterface
163      *            instance of the NeutronRouter_Interface to be detached to the router
164      * @return integer
165      *            the return value is understood to be a HTTP status code.  A return value outside of 200 through 299
166      *            results in the detach operation being interrupted and the returned status value reflected in the
167      *            HTTP response.
168      */
169     @Override
170     public int canDetachInterface(NeutronRouter router, NeutronRouter_Interface routerInterface) {
171         logger.debug(" Router {} asked if it can detach interface {}. Subnet {}",
172                      router.getName(),
173                      routerInterface.getPortUUID(),
174                      routerInterface.getSubnetUUID());
175
176         return HttpURLConnection.HTTP_OK;
177     }
178
179     /**
180      * Services provide this interface method for taking action after an interface has been removed from a router
181      *
182      * @param router
183      *            instance of the base Neutron Router object
184      * @param routerInterface
185      *            instance of the NeutronRouter_Interface being detached from the router
186      */
187     @Override
188     public void neutronRouterInterfaceDetached(NeutronRouter router, NeutronRouter_Interface routerInterface) {
189         logger.debug(" Router {} interface {} detached. Subnet {}", router.getName(), routerInterface.getPortUUID(),
190                      routerInterface.getSubnetUUID());
191     }
192 }