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} ClusterKeywords.Get Cluster Shard Status ${controller_index_list} config inventory
19 ${inv_oper_leader} ${inv_oper_followers_list} ClusterKeywords.Get Cluster Shard Status ${controller_index_list} operational inventory
20 ${topo_oper_leader} ${topo_oper_followers_list} ClusterKeywords.Get Cluster Shard Status ${controller_index_list} operational topology
21 ${owner_oper_leader} ${owner_oper_followers_list} ClusterKeywords.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 ClusterOpenFlow.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}= Utils.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}= RequestsLibrary.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}= Utils.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 \ Append To List ${candidates_list} ${candidate}
61 List Should Contain Sublist ${candidates_list} ${controller_index_list} Candidates are missing in ${candidates_list}
62 Remove Values From List ${candidates_list} ${owner}
63 [Return] ${owner} ${candidates_list}
65 Get OpenFlow Entity Owner Status For One Device
66 [Arguments] ${controller_index_list} ${device}
67 [Documentation] Check Entity Owner Status and identify owner and candidate.
68 ${owner} ${candidates_list} Wait Until Keyword Succeeds 10s 1s ClusterOpenFlow.Get Cluster Entity Owner For Openflow ${controller_index_list}
69 ... openflow ${device}
70 [Return] ${owner} ${candidates_list}
72 Check OpenFlow Network Operational Information For Sample Topology
73 [Arguments] ${controller_index_list}
74 [Documentation] Check devices in tree,2 are in operational inventory and topology in all instances in ${controller_index_list}.
75 ... 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
76 ... + 5x node_id per link termination. TODO: A Keyword that can calculate this based on mininet topology.
77 ${dictionary} Create Dictionary openflow:1=4 openflow:2=5 openflow:3=5
78 Wait Until Keyword Succeeds 5s 1s ClusterKeywords.Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_NODES_API}
79 ${dictionary} Create Dictionary openflow:1=21 openflow:2=19 openflow:3=19
80 Wait Until Keyword Succeeds 5s 1s ClusterKeywords.Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
82 Check No OpenFlow Network Operational Information
83 [Arguments] ${controller_index_list}
84 [Documentation] Check device is not in operational inventory or topology in all cluster instances in ${controller_index_list}.
85 ${dictionary} Create Dictionary openflow=0
86 Wait Until Keyword Succeeds 5s 1s ClusterKeywords.Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_NODES_API}
87 ${dictionary} Create Dictionary openflow=0
88 Wait Until Keyword Succeeds 5s 1s ClusterKeywords.Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
90 Add Sample Flow And Verify
91 [Arguments] ${controller_index_list} ${controller_index}
92 [Documentation] Add sample flow in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
93 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/sample_flow_1.json
94 # There are slight differences on the way He and Li plugin display table information. He plugin has an additional Hashmap field
95 # replicating some of the matches in the flows section. Same comment applies for further keywords.
96 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2 "output-node-connector":"1"=1
97 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1 "output-node-connector":"1"=1
98 ClusterKeywords.Put And Check At URI In Cluster ${controller_index_list} ${controller_index} ${config_table_0}/flow/1 ${body}
99 Wait Until Keyword Succeeds 15s 1s ClusterKeywords.Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${operational_table_0}
101 Modify Sample Flow And Verify
102 [Arguments] ${controller_index_list} ${controller_index}
103 [Documentation] Modify sample flow in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
104 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/sample_flow_2.json
105 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2 "output-node-connector":"2"=1
106 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1 "output-node-connector":"2"=1
107 ClusterKeywords.Put And Check At URI In Cluster ${controller_index_list} ${controller_index} ${config_table_0}/flow/1 ${body}
108 Wait Until Keyword Succeeds 15s 1s ClusterKeywords.Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${operational_table_0}
110 Delete Sample Flow And Verify
111 [Arguments] ${controller_index_list} ${controller_index}
112 [Documentation] Delete sample flow in Owner and verify it gets removed from all instances.
113 ${dictionary}= Create Dictionary 10.0.2.0/24=0
114 ClusterKeywords.Delete And Check At URI In Cluster ${controller_index_list} ${controller_index} ${config_table_0}/flow/1
115 Wait Until Keyword Succeeds 5s 1s ClusterKeywords.Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${operational_table_0}
117 Send RPC Add Sample Flow And Verify
118 [Arguments] ${controller_index_list} ${controller_index}
119 [Documentation] Add sample flow in ${controller_index} and verify it gets applied from all instances in ${controller_index_list}.
120 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/add_flow_rpc.json
121 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2
122 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1
123 ${resp} RequestsLibrary.Post Request controller${controller_index} /restconf/operations/sal-flow:add-flow data=${body} headers=${HEADERS_YANG_JSON}
125 Should Be Equal As Strings ${resp.status_code} 200
126 Wait Until Keyword Succeeds 15s 1s ClusterKeywords.Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${operational_table_0}
128 Send RPC Delete Sample Flow And Verify
129 [Arguments] ${controller_index_list} ${controller_index}
130 [Documentation] Delete sample flow in ${controller_index} and verify it gets removed from all instances in ${controller_index_list}.
131 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/delete_flow_rpc.json
132 ${dictionary}= Create Dictionary 10.0.1.0/24=0
133 ${resp} RequestsLibrary.Post Request controller${controller_index} /restconf/operations/sal-flow:remove-flow data=${body} headers=${HEADERS_YANG_JSON}
135 Should Be Equal As Strings ${resp.status_code} 200
136 Wait Until Keyword Succeeds 5s 1s ClusterKeywords.Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${operational_table_0}
138 Take OpenFlow Device Link Down and Verify
139 [Arguments] ${controller_index_list}
140 [Documentation] Take a link down and verify port status in all instances in ${controller_index_list}.
141 ${dictionary}= Create Dictionary "link-down":true=1
142 ${ouput}= MininetKeywords.Send Mininet Command ${mininet_conn_id} link s1 s2 down
143 Wait Until Keyword Succeeds 5s 1s ClusterKeywords.Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${operational_port_1}
144 ${dictionary} Create Dictionary openflow:1=16 openflow:2=14 openflow:3=19
145 Wait Until Keyword Succeeds 20s 2s ClusterKeywords.Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
147 Take OpenFlow Device Link Up and Verify
148 [Arguments] ${controller_index_list}
149 [Documentation] Take the link up and verify port status in all instances in ${controller_index_list}.
150 ${dictionary}= Create Dictionary "link-down":true=0
151 ${ouput}= MininetKeywords.Send Mininet Command ${mininet_conn_id} link s1 s2 up
152 Wait Until Keyword Succeeds 5s 1s ClusterKeywords.Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${operational_port_1}
153 ${dictionary} Create Dictionary openflow:1=21 openflow:2=19 openflow:3=19
154 Wait Until Keyword Succeeds 5s 1s ClusterKeywords.Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}