2 Documentation Cluster OpenFlow library. So far this library is only to be used by OpenFlow cluster test as it is very specific for this test.
3 Library RequestsLibrary
4 Resource ClusterKeywords.robot
5 Resource MininetKeywords.robot
7 Variables ../variables/Variables.py
10 ${config_table_0} ${CONFIG_NODES_API}/node/openflow:1/table/0
11 ${operational_table_0} ${OPERATIONAL_NODES_API}/node/openflow:1/table/0
12 ${operational_port_1} ${OPERATIONAL_NODES_API}/node/openflow:1/node-connector/openflow:1:1
15 Check OpenFlow Shards Status
16 [Arguments] ${controller_index_list}
17 [Documentation] Check Status for all shards in OpenFlow application.
18 ${inv_conf_leader} ${inv_conf_followers_list} Get Cluster Shard Status ${controller_index_list} config inventory
19 ${inv_oper_leader} ${inv_oper_followers_list} Get Cluster Shard Status ${controller_index_list} operational inventory
20 ${topo_oper_leader} ${topo_oper_followers_list} Get Cluster Shard Status ${controller_index_list} operational topology
21 ${owner_oper_leader} ${owner_oper_followers_list} Get Cluster Shard Status ${controller_index_list} operational entity-ownership
22 Log config inventory Leader is ${inv_conf_leader} and followers are ${inv_conf_followers_list}
23 Log operational inventory Leader is ${inv_oper_leader} and followers are ${inv_oper_followers_list}
24 Log operational topology Leader is ${topo_oper_leader} and followers are ${topo_oper_followers_list}
25 Log operational entity-ownership Leader is ${owner_oper_leader} and followers are ${owner_oper_followers_list}
27 Check OpenFlow Shards Status After Cluster Event
28 [Arguments] ${controller_index_list}
29 [Documentation] Check Shards Status after some cluster event.
30 Wait Until Keyword Succeeds 90s 1s Check OpenFlow Shards Status ${controller_index_list}
32 Get Cluster Entity Owner For Openflow
33 [Arguments] ${controller_index_list} ${device_type} ${device}
34 [Documentation] Checks OpenFlow Entity Owner status for a ${device} and returns owner index and list of candidates from a ${controller_index_list}.
35 ... ${device_type} is normally openflow.
36 ${length}= Get Length ${controller_index_list}
37 ${candidates_list}= Create List
38 ${data}= Get Data From URI controller@{controller_index_list}[0] /restconf/operational/entity-owners:entity-owners
40 ${data}= Replace String ${data} /general-entity:entity[general-entity:name=' ${EMPTY}
41 ${clear_data}= Replace String ${data} '] ${EMPTY}
43 ${json}= To Json ${clear_data}
44 ${entity_type_list}= Get From Dictionary &{json}[entity-owners] entity-type
45 ${entity_type_index}= Get Index From List Of Dictionaries ${entity_type_list} type ${device_type}
46 Should Not Be Equal ${entity_type_index} -1 No Entity Owner found for ${device_type}
47 ${entity_list}= Get From Dictionary @{entity_type_list}[${entity_type_index}] entity
48 ${entity_index}= Get Index From List Of Dictionaries ${entity_list} id ${device}
49 Should Not Be Equal ${entity_index} -1 Device ${device} not found in Entity Owner ${device_type}
50 ${entity_owner}= Get From Dictionary @{entity_list}[${entity_index}] owner
51 Should Not Be Empty ${entity_owner} No owner found for ${device}
52 ${owner}= Replace String ${entity_owner} member- ${EMPTY}
53 ${owner}= Convert To Integer ${owner}
54 List Should Contain Value ${controller_index_list} ${owner} Owner ${owner} not exisiting in ${controller_index_list}
55 ${entity_candidates_list}= Get From Dictionary @{entity_list}[${entity_index}] candidate
56 ${list_length}= Get Length ${entity_candidates_list}
57 : FOR ${entity_candidate} IN @{entity_candidates_list}
58 \ ${candidate}= Replace String &{entity_candidate}[name] member- ${EMPTY}
59 \ ${candidate}= Convert To Integer ${candidate}
60 \ Run Keyword If '${candidate}' != '${owner}' Append To List ${candidates_list} ${candidate}
61 [Return] ${owner} ${candidates_list}
63 Get OpenFlow Entity Owner Status For One Device
64 [Arguments] ${controller_index_list}
65 [Documentation] Check Entity Owner Status and identify owner and candidate.
66 ${owner} ${candidates_list} Wait Until Keyword Succeeds 10s 1s Get Cluster Entity Owner For Openflow ${controller_index_list}
67 ... openflow openflow:1
68 [Return] ${owner} ${candidates_list}
70 Check OpenFlow Network Operational Information For One Device
71 [Arguments] ${controller_index_list}
72 [Documentation] Check device openflow:1 is in operational inventory and topology in all instances in ${controller_index_list}.
73 ... Inventory should show 1x node_id per device 1x node_id per connector. Topology should show 2x node_id per device + 3x node_id per connector.
74 ${dictionary} Create Dictionary openflow:1=4
75 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_NODES_API}
76 ${dictionary} Create Dictionary openflow:1=11
77 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
79 Check No OpenFlow Network Operational Information
80 [Arguments] ${controller_index_list}
81 [Documentation] Check device is not in operational inventory or topology in all cluster instances in ${controller_index_list}.
82 ${dictionary} Create Dictionary openflow=0
83 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_NODES_API}
84 ${dictionary} Create Dictionary openflow=0
85 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
87 Add Sample Flow And Verify
88 [Arguments] ${controller_index_list} ${controller_index}
89 [Documentation] Add sample flow in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
90 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/sample_flow_1.json
91 # There are slight differences on the way He and Li plugin display table information. He plugin has an additional Hashmap field
92 # replicating some of the matches in the flows section. Same comment applies for further keywords.
93 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2 "output-node-connector":"1"=1
94 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1 "output-node-connector":"1"=1
95 Put And Check At URI In Cluster ${controller_index_list} ${controller_index} ${config_table_0}/flow/1 ${body}
96 Wait Until Keyword Succeeds 15s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${operational_table_0}
98 Modify Sample Flow And Verify
99 [Arguments] ${controller_index_list} ${controller_index}
100 [Documentation] Modify sample flow in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
101 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/sample_flow_2.json
102 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2 "output-node-connector":"2"=1
103 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1 "output-node-connector":"2"=1
104 Put And Check At URI In Cluster ${controller_index_list} ${controller_index} ${config_table_0}/flow/1 ${body}
105 Wait Until Keyword Succeeds 15s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${operational_table_0}
107 Delete Sample Flow And Verify
108 [Arguments] ${controller_index_list} ${controller_index}
109 [Documentation] Delete sample flow in Owner and verify it gets removed from all instances.
110 ${dictionary}= Create Dictionary 10.0.2.0/24=0
111 Delete And Check At URI In Cluster ${controller_index_list} ${controller_index} ${config_table_0}/flow/1
112 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${operational_table_0}
114 Send RPC Add Sample Flow And Verify
115 [Arguments] ${controller_index_list} ${controller_index}
116 [Documentation] Add sample flow in ${controller_index} and verify it gets applied from all instances in ${controller_index_list}.
117 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/add_flow_rpc.json
118 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2
119 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1
120 ${resp} RequestsLibrary.Post Request controller${controller_index} /restconf/operations/sal-flow:add-flow data=${body} headers=${HEADERS_YANG_JSON}
122 Should Be Equal As Strings ${resp.status_code} 200
123 Wait Until Keyword Succeeds 15s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${operational_table_0}
125 Send RPC Delete Sample Flow And Verify
126 [Arguments] ${controller_index_list} ${controller_index}
127 [Documentation] Delete sample flow in ${controller_index} and verify it gets removed from all instances in ${controller_index_list}.
128 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/delete_flow_rpc.json
129 ${dictionary}= Create Dictionary 10.0.1.0/24=0
130 ${resp} RequestsLibrary.Post Request controller${controller_index} /restconf/operations/sal-flow:remove-flow data=${body} headers=${HEADERS_YANG_JSON}
132 Should Be Equal As Strings ${resp.status_code} 200
133 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${operational_table_0}
135 Take OpenFlow Device Link Down and Verify
136 [Arguments] ${controller_index_list}
137 [Documentation] Take a link down and verify port status in all instances in ${controller_index_list}.
138 ${dictionary}= Create Dictionary "link-down":true=1
139 ${ouput}= Send Mininet Command ${mininet_conn_id} link s1 h1 down
140 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${operational_port_1}
142 Take OpenFlow Device Link Up and Verify
143 [Arguments] ${controller_index_list}
144 [Documentation] Take the link up and verify port status in all instances in ${controller_index_list}.
145 ${dictionary}= Create Dictionary "link-down":true=0
146 ${ouput}= Send Mininet Command ${mininet_conn_id} link s1 h1 up
147 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${operational_port_1}