On Wed, Jan 18, 2012 at 10:52:36AM -0800, Chuan Wang wrote:
> How do I create a transaction so that the newly created "controller"
> is referred? I can see the "Bridge" has a column controller, but it
> requires the controller's uuid, which is created automatically and
> returned by ovsdb. Since the controller is GC'ed immediately after
> my transaction, seems like I cannot get a hold on it...

You can watch what ovs-vsctl does:

# ovs-vsctl -vjsonrpc --no-wait set-controller br0 tcp:192.168.0.3
Jan 18 11:37:58|00002|jsonrpc|DBG|unix:/var/run/openvswitch/db.sock: send 
request, method="monitor", 
params=["Open_vSwitch",null,{"Port":{"columns":["fake_bridge","interfaces","name","tag"]},"Controller":{"columns":["target"]},"Interface":{"columns":["name"]},"Open_vSwitch":{"columns":["bridges"]},"Bridge":{"columns":["controller","fail_mode","name","ports"]}}],
 id=0
Jan 18 11:37:58|00003|jsonrpc|DBG|unix:/var/run/openvswitch/db.sock: received 
reply, 
result={"Port":{"a528168c-114f-4cac-8739-24857158e003":{"new":{"interfaces":["uuid","efd649ce-106f-46af-ac08-b34c17e7e613"],"name":"eth2","fake_bridge":false,"tag":["set",[]]}},"67234881-62dc-406e-9f3f-fa0d34e4dced":{"new":{"interfaces":["uuid","89ee664d-1f28-4d10-825d-c6b0641e584d"],"name":"br0","fake_bridge":false,"tag":["set",[]]}},"c042dacb-0bdc-4274-8428-683f03d395a3":{"new":{"interfaces":["uuid","40301a4b-7fe3-45a2-bf0f-75279918a64a"],"name":"eth1","fake_bridge":false,"tag":["set",[]]}},"cb8b0a10-84a6-4615-8cc9-0a3bfed625d5":{"new":{"interfaces":["uuid","0b11cddb-094d-4857-9abc-cc55e872634d"],"name":"eth0","fake_bridge":false,"tag":["set",[]]}}},"Interface":{"40301a4b-7fe3-45a2-bf0f-75279918a64a":{"new":{"name":"eth1"}},"efd649ce-106f-46af-ac08-b34c17e7e613":{"new":{"name":"eth2"}},"89ee664d-1f28-4d10-825d-c6b0641e584d":{"new":{"name":"br0"}},"0b11cddb-094d-4857-9abc-cc55e872634d":{"new
 
":{"name":"eth0"}}},"Open_vSwitch":{"0b4a60f3-6a63-4a38-a8e7-c017d2f2d24d":{"new":{"bridges":["uuid","a0e891b7-e8da-408c-9d26-0c94ab215b8b"]}}},"Bridge":{"a0e891b7-e8da-408c-9d26-0c94ab215b8b":{"new":{"name":"br0","ports":["set",[["uuid","67234881-62dc-406e-9f3f-fa0d34e4dced"],["uuid","a528168c-114f-4cac-8739-24857158e003"],["uuid","c042dacb-0bdc-4274-8428-683f03d395a3"],["uuid","cb8b0a10-84a6-4615-8cc9-0a3bfed625d5"]]],"fail_mode":["set",[]],"controller":["set",[]]}}}},
 id=0
Jan 18 11:37:58|00004|jsonrpc|DBG|unix:/var/run/openvswitch/db.sock: send 
request, method="transact", 
params=["Open_vSwitch",{"rows":[{"bridges":["uuid","a0e891b7-e8da-408c-9d26-0c94ab215b8b"]}],"until":"==","where":[["_uuid","==",["uuid","0b4a60f3-6a63-4a38-a8e7-c017d2f2d24d"]]],"timeout":0,"op":"wait","table":"Open_vSwitch","columns":["bridges"]},{"rows":[{"controller":["set",[]]}],"until":"==","where":[["_uuid","==",["uuid","a0e891b7-e8da-408c-9d26-0c94ab215b8b"]]],"timeout":0,"op":"wait","table":"Bridge","columns":["controller"]},{"uuid-name":"rowf3e85caa_997a_40fb_8b00_bad3beed7ad0","op":"insert","table":"Controller","row":{"target":"tcp:192.168.0.3"}},{"where":[["_uuid","==",["uuid","a0e891b7-e8da-408c-9d26-0c94ab215b8b"]]],"op":"update","table":"Bridge","row":{"controller":["named-uuid","rowf3e85caa_997a_40fb_8b00_bad3beed7ad0"]}},{"comment":"ovs-vsctl:
 ovs-vsctl -vjsonrpc --no-wait set-controller br0 
tcp:192.168.0.3","op":"comment"}], id=1
Jan 18 11:37:58|00005|jsonrpc|DBG|unix:/var/run/openvswitch/db.sock: received 
notification, method="update", 
params=[null,{"Controller":{"737fe8f0-b650-48b3-b0a2-30faef353098":{"new":{"target":"tcp:192.168.0.3"}}},"Bridge":{"a0e891b7-e8da-408c-9d26-0c94ab215b8b":{"old":{"controller":["set",[]]},"new":{"name":"br0","ports":["set",[["uuid","67234881-62dc-406e-9f3f-fa0d34e4dced"],["uuid","a528168c-114f-4cac-8739-24857158e003"],["uuid","c042dacb-0bdc-4274-8428-683f03d395a3"],["uuid","cb8b0a10-84a6-4615-8cc9-0a3bfed625d5"]]],"fail_mode":["set",[]],"controller":["uuid","737fe8f0-b650-48b3-b0a2-30faef353098"]}}}}]
Jan 18 11:37:58|00006|jsonrpc|DBG|unix:/var/run/openvswitch/db.sock: received 
reply, 
result=[{},{},{"uuid":["uuid","737fe8f0-b650-48b3-b0a2-30faef353098"]},{"count":1},{}],
 id=1
# tests/test-json --pretty - 
["Open_vSwitch",{"rows":[{"bridges":["uuid","a0e891b7-e8da-408c-9d26-0c94ab215b8b"]}],"until":"==","where":[["_uuid","==",["uuid","0b4a60f3-6a63-4a38-a8e7-c017d2f2d24d"]]],"timeout":0,"op":"wait","table":"Open_vSwitch","columns":["bridges"]},{"rows":[{"controller":["set",[]]}],"until":"==","where":[["_uuid","==",["uuid","a0e891b7-e8da-408c-9d26-0c94ab215b8b"]]],"timeout":0,"op":"wait","table":"Bridge","columns":["controller"]},{"uuid-name":"rowf3e85caa_997a_40fb_8b00_bad3beed7ad0","op":"insert","table":"Controller","row":{"target":"tcp:192.168.0.3"}},{"where":[["_uuid","==",["uuid","a0e891b7-e8da-408c-9d26-0c94ab215b8b"]]],"op":"update","table":"Bridge","row":{"controller":["named-uuid","rowf3e85caa_997a_40fb_8b00_bad3beed7ad0"]}},{"comment":"ovs-vsctl:
 ovs-vsctl -vjsonrpc --no-wait set-controller br0 
tcp:192.168.0.3","op":"comment"}] 
[
  "Open_vSwitch",
  {
    "columns": [
      "bridges"],
    "op": "wait",
    "rows": [
      {
        "bridges": [
          "uuid",
          "a0e891b7-e8da-408c-9d26-0c94ab215b8b"]}],
    "table": "Open_vSwitch",
    "timeout": 0,
    "until": "==",
    "where": [
      [
        "_uuid",
        "==",
        [
          "uuid",
          "0b4a60f3-6a63-4a38-a8e7-c017d2f2d24d"]]]},
  {
    "columns": [
      "controller"],
    "op": "wait",
    "rows": [
      {
        "controller": [
          "set",
          []]}],
    "table": "Bridge",
    "timeout": 0,
    "until": "==",
    "where": [
      [
        "_uuid",
        "==",
        [
          "uuid",
          "a0e891b7-e8da-408c-9d26-0c94ab215b8b"]]]},
  {
    "op": "insert",
    "row": {
      "target": "tcp:192.168.0.3"},
    "table": "Controller",
    "uuid-name": "rowf3e85caa_997a_40fb_8b00_bad3beed7ad0"},
  {
    "op": "update",
    "row": {
      "controller": [
        "named-uuid",
        "rowf3e85caa_997a_40fb_8b00_bad3beed7ad0"]},
    "table": "Bridge",
    "where": [
      [
        "_uuid",
        "==",
        [
          "uuid",
          "a0e891b7-e8da-408c-9d26-0c94ab215b8b"]]]},
  {
    "comment": "ovs-vsctl: ovs-vsctl -vjsonrpc --no-wait set-controller br0 
tcp:192.168.0.3",
    "op": "comment"}]
_______________________________________________
discuss mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/discuss

Reply via email to