Ovsdb plugin compatibility layer
[netvirt.git] / ovsdb-plugin-compatibility-layer / src / main / java / org / opendaylight / ovsdb / compatibility / plugin / impl / ConfigurationServiceImpl.java
1 /*
2  * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
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 package org.opendaylight.ovsdb.compatibility.plugin.impl;
9
10 import java.util.List;
11 import java.util.concurrent.ConcurrentMap;
12 import java.util.concurrent.ExecutionException;
13
14 import org.opendaylight.controller.sal.core.Node;
15 import org.opendaylight.controller.sal.utils.Status;
16 import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbConfigurationService;
17 import org.opendaylight.ovsdb.compatibility.plugin.api.StatusWithUuid;
18 import org.opendaylight.ovsdb.compatibility.plugin.error.OvsdbPluginException;
19 import org.opendaylight.ovsdb.lib.notation.Row;
20 import org.opendaylight.ovsdb.lib.notation.UUID;
21 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
22 import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable;
23
24 /**
25  * This is a proxy class for ovsdb plugin's OvsdbConfigurationService class
26  * It just forward the call to OvsdbConfigurationService instance and pass
27  * back the response to the caller.
28  *
29  * @author Anil Vishnoi (vishnoianil@gmail.com)
30  *
31  */
32 public class ConfigurationServiceImpl implements OvsdbConfigurationService
33 {
34     org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService pluginOvsdbConfigurationService;
35
36     void init() {
37     }
38
39     /**
40      * Function called by the dependency manager when at least one dependency
41      * become unsatisfied or when the component is shutting down because for
42      * example bundle is being stopped.
43      *
44      */
45     void destroy() {
46     }
47
48     /**
49      * Function called by dependency manager after "init ()" is called and after
50      * the services provided by the class are registered in the service registry
51      *
52      */
53     void start() {
54     }
55
56     /**
57      * Function called by the dependency manager before the services exported by
58      * the component are unregistered, this will be followed by a "destroy ()"
59      * calls
60      *
61      */
62     void stop() {
63     }
64
65     public void setOvsdbConfigurationService(org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService pluginOvsdbConfigurationService){
66         this.pluginOvsdbConfigurationService = pluginOvsdbConfigurationService;
67     }
68
69     public void unsetOvsdbConfigurationService(org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService pluginOvsdbConfigurationService){
70         if(this.pluginOvsdbConfigurationService != null)
71             this.pluginOvsdbConfigurationService = null;
72     }
73
74
75     @Override
76     public StatusWithUuid insertRow(Node node, String tableName, String parentUuid, Row<GenericTableSchema> row) {
77         return StatusConvertorUtil.convertOvsdbStatusWithUuidToCompLayerStatusWithUuid(pluginOvsdbConfigurationService.insertRow(node, tableName, parentUuid, row));
78     }
79
80     @Override
81     public Status updateRow (Node node, String tableName, String parentUUID, String rowUUID, Row row) {
82         return StatusConvertorUtil.convertOvsdbStatusToSalStatus(pluginOvsdbConfigurationService.updateRow(node, tableName, parentUUID, rowUUID, row));
83     }
84
85     @Override
86     public Status deleteRow(Node node, String tableName, String uuid) {
87         return StatusConvertorUtil.convertOvsdbStatusToSalStatus(pluginOvsdbConfigurationService.deleteRow(node, tableName, uuid));
88     }
89
90     @Override
91     public ConcurrentMap<String, Row> getRows(Node node, String tableName) {
92         return pluginOvsdbConfigurationService.getRows(node, tableName);
93     }
94
95     @Override
96     public Row getRow(Node node, String tableName, String uuid) {
97         return pluginOvsdbConfigurationService.getRow(node, tableName, uuid);
98     }
99
100     @Override
101     public List<String> getTables(Node node) {
102         return pluginOvsdbConfigurationService.getTables(node);
103     }
104
105     @Override
106     public Boolean setOFController(Node node, String bridgeUUID) throws InterruptedException, ExecutionException {
107         return pluginOvsdbConfigurationService.setOFController(node, bridgeUUID);
108     }
109
110     @Override
111     public <T extends TypedBaseTable<?>> String getTableName(Node node, Class<T> typedClass) {
112         return pluginOvsdbConfigurationService.getTableName(node, typedClass);
113     }
114
115     @Override
116     public <T extends TypedBaseTable<?>> T getTypedRow(Node node, Class<T> typedClass, Row row) {
117         return pluginOvsdbConfigurationService.getTypedRow(node, typedClass, row);
118     }
119
120     @Override
121     public <T extends TypedBaseTable<?>> T createTypedRow(Node node, Class<T> typedClass) {
122         return pluginOvsdbConfigurationService.createTypedRow(node, typedClass);
123     }
124
125     @Override
126     public UUID insertRow(Node node, String databaseName, String tableName, String parentTable, UUID parentUuid,
127                           String parentColumn, Row<GenericTableSchema> row) throws OvsdbPluginException {
128         return pluginOvsdbConfigurationService.insertRow(node, databaseName, tableName, parentTable, parentUuid,
129                 parentColumn, row);
130     }
131
132     @Override
133     public UUID insertRow(Node node, String databaseName, String tableName,
134             UUID parentRowUuid, Row<GenericTableSchema> row)
135             throws OvsdbPluginException {
136         return this.insertRow(node, databaseName, tableName, null, parentRowUuid, null, row);
137     }
138
139     @Override
140     public Row<GenericTableSchema> insertTree(Node node, String databaseName, String tableName, String parentTable, UUID parentUuid,
141                                               String parentColumn, Row<GenericTableSchema> row) throws OvsdbPluginException {
142         return pluginOvsdbConfigurationService.insertTree(node, databaseName, tableName, parentTable, parentUuid, parentColumn, row);
143     }
144
145     @Override
146     public Row<GenericTableSchema> insertTree(Node node, String databaseName,
147             String tableName, UUID parentRowUuid, Row<GenericTableSchema> row)
148             throws OvsdbPluginException {
149         return this.insertTree(node, databaseName, tableName, null, parentRowUuid, null, row);
150     }
151
152     @Override
153     public Row<GenericTableSchema> updateRow(Node node, String databaseName,
154             String tableName, UUID rowUuid, Row<GenericTableSchema> row,
155             boolean overwrite) throws OvsdbPluginException {
156         return pluginOvsdbConfigurationService.updateRow(node, databaseName, tableName, rowUuid, row, overwrite);
157     }
158
159     @Override
160     public void deleteRow(Node node, String databaseName, String tableName, String parentTable, UUID parentRowUuid,
161             String parentColumn, UUID rowUuid) throws OvsdbPluginException {
162         pluginOvsdbConfigurationService.deleteRow(node, databaseName, tableName, parentTable, parentRowUuid, parentColumn, rowUuid);
163     }
164
165     @Override
166     public void deleteRow(Node node, String databaseName, String tableName, UUID rowUuid) throws OvsdbPluginException {
167         this.deleteRow(node, databaseName, tableName, null, null, null, rowUuid);
168     }
169
170     @Override
171     public Row<GenericTableSchema> getRow(Node node, String databaseName,
172             String tableName, UUID uuid) throws OvsdbPluginException {
173         return pluginOvsdbConfigurationService.getRow(node, databaseName, tableName, uuid);
174     }
175
176     @Override
177     public ConcurrentMap<UUID, Row<GenericTableSchema>> getRows(Node node,
178             String databaseName, String tableName) throws OvsdbPluginException {
179         return pluginOvsdbConfigurationService.getRows(node, databaseName, tableName);
180     }
181
182     @Override
183     public ConcurrentMap<UUID, Row<GenericTableSchema>> getRows(Node node,
184             String databaseName, String tableName, String fiqlQuery)
185             throws OvsdbPluginException {
186         return this.getRows(node, databaseName, tableName);
187     }
188
189     @Override
190     public List<String> getTables(Node node, String databaseName) throws OvsdbPluginException {
191         return pluginOvsdbConfigurationService.getTables(node, databaseName);
192     }
193 }