Code ReOrganization and Re-Architecture changes
[ovsdb.git] / library / src / main / java / org / opendaylight / ovsdb / lib / database / OVSInstance.java
1 /*
2  * [[ Authors will Fill in the Copyright header ]]
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 : Brent Salisbury, Evan Zeller
9  */
10 package org.opendaylight.ovsdb.lib.database;
11
12 import java.util.ArrayList;
13 import java.util.HashMap;
14 import java.util.List;
15 import java.util.Map;
16
17 public class OVSInstance {
18     private String uuid;
19
20     public OVSInstance(){
21         this.uuid = null;
22     }
23
24     public OVSInstance(String uuid){
25         this.uuid = uuid;
26     }
27
28     @SuppressWarnings("unchecked")
29     public static OVSInstance monitorOVS(){
30         List<String> columns = new ArrayList<String>();
31         columns.add("_uuid");
32         columns.add("bridges");
33
34         Map<String, List<String>> row = new HashMap<String, List<String>>();
35         row.put("columns", columns);
36
37         Map<String, Map> tables = new HashMap<String, Map>();
38         tables.put("Open_vSwitch", row);
39
40         Object[] params = {"Open_vSwitch", null, tables};
41
42         Map<String, Object> monitorResponse = new HashMap<String, Object>();
43
44         Map<String, Object> vSwitchTable = (Map) monitorResponse.get("Open_vSwitch");
45         if(vSwitchTable != null){
46             String uuid = (String) vSwitchTable.keySet().toArray()[0];
47             return new OVSInstance(uuid);
48         }
49         return null;
50     }
51
52     public String getUuid(){
53         return this.uuid;
54     }
55
56 }