/* * [[ Authors will Fill in the Copyright header ]] * * 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 : Brent Salisbury, Evan Zeller */ package org.opendaylight.ovsdb.lib.database; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import org.opendaylight.ovsdb.plugin.Connection; import org.opendaylight.ovsdb.plugin.OvsdbMessage; public class OVSBridge { private String uuid; private String name; public OVSBridge(String uuid, String name){ this.uuid = uuid; this.name = name; } public String getUuid(){ return this.uuid; } public String getName(){ return this.name; } @SuppressWarnings("unchecked") public static Map monitorBridge(Connection connection){ List columns = new ArrayList(); columns.add("_uuid"); columns.add("name"); Map> row = new HashMap>(); row.put("columns", columns); Map tables = new HashMap(); tables.put("Bridge", row); Object[] params = {"Open_vSwitch", null, tables}; OvsdbMessage msg = new OvsdbMessage("monitor", params); Map monitorResponse = new HashMap(); Map bridgeTable = (Map) monitorResponse.get("Bridge"); Object[] uuidObjects = bridgeTable.keySet().toArray(); String[] uuids = Arrays.copyOf(uuidObjects, uuidObjects.length, String[].class); Map result = new HashMap(); for(String uuid : uuids){ Map newRow = (Map) bridgeTable.get(uuid); Map newColumns = (Map) newRow.get("new"); String name = (String) newColumns.get("name"); result.put(name, new OVSBridge(uuid, name)); } return result; } }