/* * [[ 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 org.opendaylight.ovsdb.plugin.Connection; import org.opendaylight.ovsdb.plugin.OvsdbMessage; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class OVSInstance { private String uuid; public OVSInstance(){ this.uuid = null; } public OVSInstance(String uuid){ this.uuid = uuid; } @SuppressWarnings("unchecked") public static OVSInstance monitorOVS(Connection connection){ List columns = new ArrayList(); columns.add("_uuid"); columns.add("bridges"); Map> row = new HashMap>(); row.put("columns", columns); Map tables = new HashMap(); tables.put("Open_vSwitch", row); Object[] params = {"Open_vSwitch", null, tables}; OvsdbMessage msg = new OvsdbMessage("monitor", params); Map monitorResponse = new HashMap(); Map vSwitchTable = (Map) monitorResponse.get("Open_vSwitch"); if(vSwitchTable != null){ String uuid = (String) vSwitchTable.keySet().toArray()[0]; return new OVSInstance(uuid); } return null; } public String getUuid(){ return this.uuid; } }