Map<String, OVSBridge> existingBridges = OVSBridge.monitorBridge(connection);
- OVSBridge bridge = existingBridges.get(bridgeIdentifier);
+ OVSBridge ovstableid = existingBridges.get(bridgeIdentifier);
List<String> portUuidPair = new ArrayList<String>();
portUuidPair.add("named-uuid");
List<String> bridgeUuidPair = new ArrayList<String>();
bridgeUuidPair.add("uuid");
- bridgeUuidPair.add(bridge.getUuid());
+ bridgeUuidPair.add(ovstableid.getUuid());
List<Object> whereInner = new ArrayList<Object>();
whereInner.add("_uuid");
return true;
}
+ /**
+ * Implements the OVS Connection for Managers
+ *
+ * @param node Node serving this configuration service
+ * @param String with IP and connection types
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public boolean setManager(Node node, String managerip) throws Throwable{
+ try{
+ if (connectionService == null) {
+ logger.error("Couldn't refer to the ConnectionService");
+ return false;
+ }
+ Connection connection = connectionService.getConnection(node);
+
+ if (connection != null) {
+ String newmanager = "new_manager";
+
+ OVSInstance instance = OVSInstance.monitorOVS(connection);
+
+ Map ovsoutter = new LinkedHashMap();
+ Map ovsinner = new LinkedHashMap();
+ ArrayList ovsalist1 = new ArrayList();
+ ArrayList ovsalist2 = new ArrayList();
+ ArrayList ovsalist3 = new ArrayList();
+ ArrayList ovsalist4 = new ArrayList();
+
+ //OVS Table Update
+ ovsoutter.put("where", ovsalist1);
+ ovsalist1.add(ovsalist2);
+ ovsalist2.add("_uuid");
+ ovsalist2.add("==");
+ ovsalist2.add(ovsalist3);
+ ovsalist3.add("uuid");
+ ovsalist3.add(instance.getUuid());
+ ovsoutter.put("op", "update");
+ ovsoutter.put("table", "Open_vSwitch");
+ ovsoutter.put("row", ovsinner);
+ ovsinner.put("manager_options", ovsalist4);
+ ovsalist4.add("named-uuid");
+ ovsalist4.add(newmanager);
+
+ Map mgroutside = new LinkedHashMap();
+ Map mgrinside = new LinkedHashMap();
+
+ //Manager Table Insert
+ mgroutside.put("uuid-name", newmanager);
+ mgroutside.put("op", "insert");
+ mgroutside.put("table","Manager");
+ mgroutside.put("row", mgrinside);
+ mgrinside.put("target", managerip);
+
+ Object[] params = {"Open_vSwitch", ovsoutter, mgroutside};
+ OvsdbMessage msg = new OvsdbMessage("transact", params);
+
+ connection.sendMessage(msg);
+ connection.readResponse(Uuid[].class);
+ }
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+ return true;
+ }
+
@Override
public Object genericConfigurationEvent(Node node, Map<String, String> config) {
// TODO Auto-generated method stub
return null;
}
-
}
\ No newline at end of file
public boolean addPortVlan(Node node, String bridgeIdentifier, String portIdentifier,
int vlanid) throws Throwable;
+ /**
+ * Create a Port with a user defined VLAN, and attach it to the specified bridge.
+ *
+ * Ex. ovs-vsctl add-port JUNIT_BRIDGE_TEST Jvlanvif0 tag=100
+ * @param node Node serving this configuration service
+ * @param bridgeDomainIdentifier String representation of a Bridge Domain
+ * @param portIdentifier String representation of a user defined Port Name
+ * @param vlanid Integer note: only one VID is accepted with tag=x method
+ */
+ public boolean setManager(Node node, String managerip) throws Throwable;
+
/**
* Generic Configuration Event/Command. It is not practically possible to define all the possible combinations
* of configurations across various plugins. Hence having a generic event/command will help bridge the gap until
--- /dev/null
+package org.opendaylight.ovsdb;\r
+\r
+import org.junit.Test;\r
+import org.opendaylight.controller.sal.core.Node;\r
+import org.opendaylight.controller.sal.core.NodeConnector;\r
+import org.opendaylight.ovsdb.internal.ConfigurationService;\r
+import org.opendaylight.ovsdb.internal.ConnectionService;\r
+import org.opendaylight.ovsdb.sal.connection.ConnectionConstants;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+public class OvsdbTestSetManager {\r
+ private static final Logger logger = LoggerFactory\r
+ .getLogger(OvsdbTestSetManager.class);\r
+\r
+ @Test\r
+ public void setManager() throws Throwable{\r
+ Node.NodeIDType.registerIDType("OVS", String.class);\r
+ NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class, "OVS");\r
+\r
+ ConnectionService connectionService = new ConnectionService();\r
+ connectionService.init();\r
+ String identifier = "TEST";\r
+ Map<ConnectionConstants, String> params = new HashMap<ConnectionConstants, String>();\r
+ params.put(ConnectionConstants.ADDRESS, "172.16.58.128");\r
+\r
+ Node node = connectionService.connect(identifier, params);\r
+ if(node == null){\r
+ logger.error("Could not connect to ovsdb server");\r
+ return;\r
+ }\r
+ /**\r
+ * Implements the OVS Connection for Managers\r
+ *\r
+ * @param node Node serving this configuration service\r
+ * @param String with IP and connection type ex. type:ip:port\r
+ *\r
+ */\r
+ ConfigurationService configurationService = new ConfigurationService();\r
+ configurationService.setConnectionServiceInternal(connectionService);\r
+ configurationService.setManager(node, "ptcp:6634:172.16.58.128");\r
+ }\r
+\r
+}\r