2 Documentation Cluster Ovsdb library. So far this library is only to be used by Ovsdb cluster test as it is very specific for this test.
3 Library RequestsLibrary
4 Resource ClusterKeywords.robot
5 Resource MininetKeywords.robot
8 Variables ../variables/Variables.py
11 Check Ovsdb Shards Status
12 [Arguments] ${controller_index_list}
13 [Documentation] Check Status for all shards in Ovsdb application.
14 ${topo_conf_leader} ${topo_conf_followers_list} Get Cluster Shard Status ${controller_index_list} config topology
15 ${topo_oper_leader} ${topo_oper_followers_list} Get Cluster Shard Status ${controller_index_list} operational topology
16 ${owner_oper_leader} ${owner_oper_followers_list} Get Cluster Shard Status ${controller_index_list} operational entity-ownership
17 Log config topology Leader is ${topo_conf_leader} and followers are ${topo_conf_followers_list}
18 Log operational topology Leader is ${topo_oper_leader} and followers are ${topo_oper_followers_list}
19 Log operational entity-ownership Leader is ${owner_oper_leader} and followers are ${owner_oper_followers_list}
21 Check Ovsdb Shards Status After Cluster Event
22 [Arguments] ${controller_index_list}
23 [Documentation] Check Shard Status after some cluster event.
24 Wait Until Keyword Succeeds 90s 1s Check Ovsdb Shards Status ${controller_index_list}
26 Get Ovsdb Entity Owner Status For One Device
27 [Arguments] ${controller_index_list}
28 [Documentation] Check Entity Owner Status and identify owner and candidate.
29 ${owner} ${candidates_list} Wait Until Keyword Succeeds 20s 1s Get Cluster Entity Owner For Ovsdb ${controller_index_list}
31 [Return] ${owner} ${candidates_list}
33 Get Cluster Entity Owner For Ovsdb
34 [Arguments] ${controller_index_list} ${device_type} ${device}
35 [Documentation] Checks Entity Owner status for a ${device} and returns owner index and list of candidates from a ${controller_index_list}.
36 ... ${device_type} is openflow, ovsdb, etc...
37 ${length}= Get Length ${controller_index_list}
38 ${candidates_list}= Create List
39 ${data}= Get Data From URI controller@{controller_index_list}[0] /restconf/operational/entity-owners:entity-owners
41 ${data}= Replace String ${data} /network-topology:network-topology/network-topology:topology[network-topology:topology-id=' ${EMPTY}
42 # the UUID will not always be the same so need to use regexp to remove this string
43 ${data}= Replace String Using Regexp ${data} \/network-topology:node\\[network-topology:node-id='ovsdb://uuid/........-....-....-....-............ ${EMPTY}
45 ${clear_data}= Replace String ${data} '] ${EMPTY}
47 ${json}= To Json ${clear_data}
48 ${entity_type_list}= Get From Dictionary &{json}[entity-owners] entity-type
49 ${entity_type_index}= Get Index From List Of Dictionaries ${entity_type_list} type ${device_type}
50 Should Not Be Equal ${entity_type_index} -1 No Entity Owner found for ${device_type}
51 ${entity_list}= Get From Dictionary @{entity_type_list}[${entity_type_index}] entity
52 ${entity_index}= Get Index From List Of Dictionaries ${entity_list} id ${device}
53 Should Not Be Equal ${entity_index} -1 Device ${device} not found in Entity Owner ${device_type}
54 ${entity_owner}= Get From Dictionary @{entity_list}[${entity_index}] owner
55 Should Not Be Empty ${entity_owner} No owner found for ${device}
56 ${owner}= Replace String ${entity_owner} member- ${EMPTY}
57 ${owner}= Convert To Integer ${owner}
58 List Should Contain Value ${controller_index_list} ${owner} Owner ${owner} not exisiting in ${controller_index_list}
59 ${entity_candidates_list}= Get From Dictionary @{entity_list}[${entity_index}] candidate
60 ${list_length}= Get Length ${entity_candidates_list}
61 : FOR ${entity_candidate} IN @{entity_candidates_list}
62 \ ${candidate}= Replace String &{entity_candidate}[name] member- ${EMPTY}
63 \ ${candidate}= Convert To Integer ${candidate}
64 \ Run Keyword If '${candidate}' != '${owner}' Append To List ${candidates_list} ${candidate}
65 [Return] ${owner} ${candidates_list}
67 Create Bridge And Verify
68 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
69 [Documentation] Create bridge in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
70 # need to get UUID which should be the same on all controllers in cluster, so asking controller1
71 ${ovsdb_uuid}= Get OVSDB UUID controller_http_session=controller${controller_index}
72 Set Suite Variable ${ovsdb_uuid}
73 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/ovsdb/create_bridge_3node.json
74 ${body} Replace String ${body} ovsdb://127.0.0.1:61644 ovsdb://uuid/${ovsdb_uuid}
75 ${body} Replace String ${body} tcp:controller1:6633 tcp:${ODL_SYSTEM_1_IP}:6640
76 ${body} Replace String ${body} tcp:controller2:6633 tcp:${ODL_SYSTEM_2_IP}:6640
77 ${body} Replace String ${body} tcp:controller3:6633 tcp:${ODL_SYSTEM_3_IP}:6640
78 ${body} Replace String ${body} 127.0.0.1 ${MININET}
79 ${BRIDGE}= Set Variable If "${status}"=="AfterFail" br02 br01
81 ${body} Replace String ${body} br01 ${BRIDGE}
82 ${body} Replace String ${body} 61644 ${OVSDB_PORT}
84 ${TOOLS_SYSTEM_IP1} Replace String ${TOOLS_SYSTEM_IP} ${TOOLS_SYSTEM_IP} "${TOOLS_SYSTEM_IP}"
85 ${dictionary}= Create Dictionary ${TOOLS_SYSTEM_IP1}=1 ${OVSDBPORT}=4 ${BRIDGE}=1
86 Wait Until Keyword Succeeds 20s 1s Put And Check At URI In Cluster ${controller_index_list} ${controller_index} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE} ${body}
87 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}
89 Create Bridge Manually And Verify
90 [Arguments] ${controller_index_list} ${controller_index}
91 [Documentation] Create bridge in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
92 Run Command On Remote System ${TOOLS_SYSTEM_IP} sudo ovs-vsctl add-br br-s1
93 ${dictionary_operational}= Create Dictionary br-s1=5
94 ${dictionary_config}= Create Dictionary br-s1=0
95 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary_config} ${CONFIG_TOPO_API}
96 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary_operational} ${OPERATIONAL_TOPO_API}
98 Delete Bridge Manually And Verify
99 [Arguments] ${controller_index_list} ${controller_index}
100 [Documentation] Delete bridge in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
101 Run Command On Remote System ${TOOLS_SYSTEM_IP} sudo ovs-vsctl del-br br-s1
102 ${dictionary}= Create Dictionary br-s1=0
103 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
105 Delete Bridge Via Rest Call And Verify
106 [Arguments] ${controller_index_list} ${controller_index}
107 [Documentation] Delete bridge in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
108 # need to get UUID which should be the same on all controllers in cluster, so asking controller1
109 ${ovsdb_uuid}= Get OVSDB UUID controller_http_session=controller${controller_index}
110 ${dictionary}= Create Dictionary ${BRIDGE}=0
111 Wait Until Keyword Succeeds 20s 1s Delete And Check At URI In Cluster ${controller_index_list} ${controller_index} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}
112 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}
114 Create Port Via Controller
115 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
116 [Documentation] This will add port/interface to the config datastore
117 ${sample} OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_port_3node.json
118 ${body} Replace String ${sample} 192.168.1.10 ${TOOLS_SYSTEM_IP}
120 ${BRIDGE}= Set Variable If "${status}"=="AfterFail" br02 br01
122 Log URL is ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/
123 ${port_dictionary}= Create Dictionary ${BRIDGE}=7 vx2=3
124 Put And Check At URI In Cluster ${controller_index_list} ${controller_index} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/ ${body}
125 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${port_dictionary} ${OPERATIONAL_TOPO_API}
127 Modify the destination IP of Port
128 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
129 [Documentation] This will modify the dst ip of existing port
130 ${sample} OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_port_3node.json
131 ${body} Replace String ${sample} 192.168.1.10 10.0.0.19
132 ${BRIDGE}= Set Variable If "${status}"=="AfterFail" br02 br01
133 Log URL is ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/
135 Put And Check At URI In Cluster ${controller_index_list} ${controller_index} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/ ${body}
137 Delete Port And Verify
138 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
139 [Documentation] Delete port in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
140 ${dictionary}= Create Dictionary vx2=0
141 ${BRIDGE}= Set Variable If "${status}"=="AfterFail" br02 br01
142 Delete And Check At URI In Cluster ${controller_index_list} ${controller_index} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/
143 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
145 Add Port To The Manual Bridge And Verify
146 [Arguments] ${controller_index_list} ${controller_index}
147 [Documentation] Add Port in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
148 Run Command On Remote System ${TOOLS_SYSTEM_IP} sudo ovs-vsctl add-port br-s1 vx1 -- set Interface vx1 type=vxlan
149 ${dictionary_operational}= Create Dictionary vx1=2
150 ${dictionary_config}= Create Dictionary vx1=0
151 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary_config} ${CONFIG_TOPO_API}
152 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary_operational} ${OPERATIONAL_TOPO_API}
154 Get Operational Topology with modified Port
155 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
156 [Documentation] This request will fetch the operational topology after the Port is added to the bridge
157 ${port_dictionary_before_fail} Create Dictionary br01=7 vx2=3 10.0.0.19=1
158 ${port_dictionary_after_fail} Create Dictionary br02=7 vx2=3 10.0.0.19=1
159 ${port_dictionary}= Set Variable If "${status}"=="AfterFail" ${port_dictionary_after_fail} ${port_dictionary_before_fail}
160 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${port_dictionary} ${OPERATIONAL_TOPO_API}
162 Verify Bridge in Restarted Node
163 [Arguments] ${controller_index_list}
164 [Documentation] Verify Bridge in Restarted node, which is created when the node is down.
165 ${dictionary} Create Dictionary br02=6
166 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
168 Verify Port in Restarted Node
169 [Arguments] ${controller_index_list}
170 [Documentation] Verify Port in Restarted node, which is created when the node is down.
171 ${dictionary} Create Dictionary vx2=3
172 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}