2 Library RequestsLibrary
4 Library OperatingSystem
9 Variables ../variables/Variables.py
11 Library HttpLibrary.HTTP
14 ${HBASE_CLIENT} /tmp/Hbase/hbase-0.94.15/bin
15 ${CASSANDRA_CLIENT} /tmp/cassandra/apache-cassandra-2.1.12/bin
17 ${prompt_timeout} ${EMPTY}
18 ${CASSANDRA_DB_PATH} /tmp/cassandra/apache-cassandra-2.1.12/
19 ${metric_path} metricpath
20 ${metric_val} metricval
21 ${metric_log} metriclog
22 ${temp_metric_val} temp_metric_val
24 ${KARAF_PATH} ${WORKSPACE}/${BUNDLEFOLDER}
25 ${TSDR_PATH} ${KARAF_PATH}/tsdr
26 ${PURGE_PATH} ${KARAF_PATH}/etc/tsdr.data.purge.cfg
27 ${SNMP_PATH} ${KARAF_PATH}/etc/tsdr.snmp.cfg
28 ${SNMP_COMMUNITY} mib2dev\/if-mib
29 &{HEADERS_QUERY} Content-Type=application/json Content-Type=application/json
30 &{OPER_STATUS} up=1 down=2 testing=3 unknown=4 dormant=5 notPresent=6 lowerLayerDown=7
34 [Arguments] ${switch}=ovsk ${switch_count}=3
35 [Documentation] TSDR specific setup/cleanup work that can be done safely before any system.
38 ${mininet_conn_id1}= Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=120s
39 Set Suite Variable ${mininet_conn_id1}
40 Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
41 Execute Command sudo ovs-vsctl set-manager ptcp:6644
42 ${start}= Set Variable sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --topo=linear,${switch_count} --switch ${switch},protocols=OpenFlow13
48 [Arguments] ${user}=${TOOLS_SYSTEM_USER}
49 [Documentation] Configure Netflow
50 ${output}= Run Command On Controller ${TOOLS_SYSTEM_IP} sudo ovs-vsctl -- set Bridge s1 netflow=@nf -- --id=@nf create NetFlow target=\\"${ODL_SYSTEM_IP}:${NETFLOW_PORT}\\" active-timeout=10 ${user}
53 [Arguments] ${switch}=ovsk
54 [Documentation] Ping between all hosts in mininet topology.
55 Switch Connection ${mininet_conn_id1}
60 [Arguments] ${host1} ${host2}
61 [Documentation] Ping between ${host1} and ${host2}
62 Switch Connection ${mininet_conn_id1}
63 Write pingpair ${host1} ${host2}
67 [Arguments] ${pattern}
68 [Documentation] Ping between h1 and h2 and check Hbase
70 ${query_output}= Query the Data from HBaseClient count 'NETFLOW'
71 Should Match Regexp ${query_output} ${pattern}
73 Ping Pair Hosts Cassandra
74 [Arguments] ${pattern}
75 [Documentation] Ping between h1 and h2 and check Cassandra
77 ${query_output}= Count Cassandra rows select count(*) from tsdr.metriclog;
78 Should Match Regexp ${query_output} ${pattern}
80 Ping Pair Hosts HSQLDB
81 [Arguments] ${pattern}
82 [Documentation] Iperf between h1 and h2 and check Cassandra
84 ${query_output}= Issue Command On Karaf Console tsdr:list NETFLOW | wc -l
85 Should Match Regexp ${query_output} ${pattern}
88 [Documentation] Cleanup/Shutdown work that should be done at the completion of all
90 Switch Connection ${mininet_conn_id1}
93 Read Until ${DEFAULT_LINUX_PROMPT}
97 [Arguments] ${HOST}=127.0.0.1 ${purge_enabled}=true ${purge_time}=00:00:00 ${purge_interval}=1400 ${retention}=0
98 [Documentation] Write Purge file and copy it to directory.127.0.0.1 refers local controller
99 Create File purge.cfg \#TSDR Project Configuration file
100 Append To File purge.cfg \n
101 Append To File purge.cfg host=${HOST}
102 Append To File purge.cfg \n
103 Append To File purge.cfg data_purge_enabled=${purge_enabled}
104 Append To File purge.cfg \n
105 Append To File purge.cfg data_purge_time=${purge_time}
106 Append To File purge.cfg \n
107 Append To File purge.cfg data_purge_interval_in_minutes=${purge_interval}
108 Append To File purge.cfg \n
109 Append To File purge.cfg retention_time_in_hours=${retention}
110 Append To File purge.cfg \n
111 Move File purge.cfg ${PURGE_PATH}
113 Initialize the HBase for TSDR
114 [Documentation] Install and initialize the tsdr tables on HBase Server
115 ${hbase_server}= Run Command On Remote System ${ODL_SYSTEM_IP} export JAVA_HOME=/usr && ${HBASE_CLIENT}/start-hbase.sh ${TOOLS_SYSTEM_USER} ${prompt_timeout}=120
117 ${hbase_process}= Run Command On Remote System ${ODL_SYSTEM_IP} ps -ef | grep HMaster
120 Stop the HBase Server
121 [Documentation] Stop the HBase server
122 ${hbase_server}= Run Command On Remote System ${ODL_SYSTEM_IP} export JAVA_HOME=/usr && ${HBASE_CLIENT}/stop-hbase.sh ${TOOLS_SYSTEM_USER} ${prompt_timeout}=90
125 Configure the Queue on Switch
126 [Arguments] ${queue_interface} ${user}=${TOOLS_SYSTEM_USER}
127 [Documentation] Configure the 2 queues on specified openvswitch interface
128 Log Configure the queue on ${queue_interface}
129 ${output}= Run Command On Remote System ${TOOLS_SYSTEM_IP} sudo ovs-vsctl set port ${queue_interface} qos=@newqos -- --id=@newqos create qos type=linux-htb other-config:max-rate=200000000 queues=0=@q0,1=@q1,2=@q2 -- --id=@q0 create queue other-config:min-rate=100000 other-config:max-rate=200000 -- --id=@q1 create queue other-config:min-rate=10001 other-config:max-rate=300000 -- --id=@q2 create queue other-config:min-rate=300001 other-config:max-rate=200000000
132 Query the Data from HBaseClient
133 [Arguments] ${query} ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s
134 [Documentation] Execute the HBase Query and return the result
135 Log Attempting to execute ${query} on ${remote} via HbaseClient
136 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
137 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
138 Write export JAVA_HOME=/usr
139 Write ${HBASE_CLIENT}/hbase shell
140 Read Until hbase(main):001:0>
142 ${output}= Read Until hbase(main):
145 Comment ${output}= Read Until ${DEFAULT_LINUX_PROMPT}
149 Verify the Metric is Collected?
150 [Arguments] ${tsdr_cmd} ${metric} ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s
151 [Documentation] Verify the ${tsdr_cmd} output contains ${metric}
152 ${output}= Issue Command On Karaf Console ${tsdr_cmd} ${remote} ${KARAF_SHELL_PORT} ${prompt_timeout}
153 Should Contain ${output} ${metric}
156 [Arguments] ${left_str} ${right_str} ${connector}
157 [Documentation] Prepare the Hbase Filter from Tsdr List output
158 ${left_str}= Remove Space on String ${left_str}
159 ${right_str}= Remove Space on String ${right_str} 1
160 ${x}= Run Keyword If '${left_str}' == 'MetricID' Catenate ${SPACE} _
161 ... ELSE IF '${left_str}' == 'ObjectKeys' Catenate ${right_str} _
162 ... ELSE IF '${left_str}' == 'TimeStamp' Get Epoch Time ${right_str}
163 ... ELSE Catenate ${SPACE}
166 Create the Hbase table row
167 [Arguments] ${tsdr_line} ${metrics}
168 [Documentation] Create the Hbase table row from tsdr:list
169 @{words}= Split String ${tsdr_line} |
170 : FOR ${li} IN @{words}
171 \ ${key}= Fetch From Left ${li} =
172 \ ${value}= Fetch From Right ${li} =
173 \ ${each_value}= Prepare HBase Filter ${key} ${value} _
174 \ ${final}= Concatenate the String ${final} ${each_value}
175 ${query}= Concatenate the String ${metrics} ${final}
176 ${query}= Remove Space on String ${query}
179 Initialize Cassandra Tables
180 [Arguments] ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s ${key_table}=metricpath ${val_table}=metricval
181 [Documentation] Truncate Existing tables in Cassandra to Start it fresh.
182 Log Attempting to truncate tables in Cassandra
183 Run Command On Remote System ${ODL_SYSTEM_IP} sudo rm -rf ${CASSANDRA_DB_PATH}${key_table}
184 Run Command On Remote System ${ODL_SYSTEM_IP} sudo rm -rf ${CASSANDRA_DB_PATH}${val_table}
185 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
186 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
187 Write export JAVA_HOME=/usr
188 Write ${CASSANDRA_CLIENT}/cqlsh
190 Write TRUNCATE tsdr.${key_table} ;
192 Write TRUNCATE tsdr.${val_table} ;
197 Initialize Cassandra Tables Metricval
198 [Arguments] ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s ${key_table}=metricpath ${val_table}=metricval
199 [Documentation] Truncate Existing tables in Cassandra to Start it fresh
200 Log Attempting to truncate tables in Cassandra
201 Run Command On Remote System ${ODL_SYSTEM_IP} sudo rm -rf ${CASSANDRA_DB_PATH}${key_table}
202 Run Command On Remote System ${ODL_SYSTEM_IP} sudo rm -rf ${CASSANDRA_DB_PATH}${val_table}
203 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
204 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
205 Write export JAVA_HOME=/usr
206 Write ${CASSANDRA_CLIENT}/cqlsh
208 Write TRUNCATE tsdr.${val_table} ;
213 Query Metrics on H2 Datastore
214 [Arguments] ${category} ${attribute} ${nodeid}=openflow:1
215 [Documentation] Generate the JDBC query for H2 Datastore
216 ${h2_query}= Concatenate the String jdbc:query metric "select * from Metric where MetricCategory= '${category}' and
217 ${h2_query}= Concatenate the String ${h2_query} MetricName = '${attribute}' and NODEID = '${nodeid}' order by ID desc limit 5"
218 ${output}= Issue Command On Karaf Console ${h2_query} ${ODL_SYSTEM_IP} ${KARAF_SHELL_PORT} 30
222 [Arguments] ${table} ${filter} ${metric}
223 [Documentation] Scan the Hbase Table with Filter
224 ${hbase_query}= Concatenate the String scan '${table}'
225 ${hbase_query}= Concatenate the String ${hbase_query} ,{ FILTER =>\"(RowFilter(=,
226 ${hbase_query}= Concatenate the String ${hbase_query} 'regexstring:${filter}*\')) AND (RowFilter(=,
227 ${hbase_query}= Concatenate the String ${hbase_query} 'regexstring:MN=${metric}*\'))\",LIMIT=>10}
228 [Return] ${hbase_query}
231 [Arguments] ${tsdr_line}
232 [Documentation] Get Metric Value from tsdr:list
233 ${value}= Fetch From Right ${tsdr_line} |
234 ${value}= Replace String ${value} MetricValue value
235 ${value}= Replace String ${value} [m ${EMPTY}
236 ${value}= Replace String ${value} = \=
237 ${value}= Remove Space on String ${value}
238 ${value}= Convert to String ${value}
241 Verify the Metrics Attributes on Hbase Client
242 [Arguments] ${attribute} ${rowfilter} ${table}=PortStats
243 [Documentation] Verification on Metrics attributes on Hbase Client
244 ${query}= Generate HBase Query ${table} ${rowfilter} ${attribute}
245 ${out}= Query the Data from HBaseClient ${query}
246 Should Match Regexp ${out} (?mui)value
248 Verify the Metrics Attributes on Cassandra Client
249 [Arguments] ${pattern}
250 [Documentation] Verification on Metrics attributes on Cassandra Client
251 @{metric_row}= Find Metricval Keys ${pattern} metricpath
252 ${keya}= Get From List ${metric_row} 1
253 ${keyb}= Get From List ${metric_row} 2
254 ${keya_bool}= Evaluate ${keya} < 0
255 ${keya}= Run Keyword If '${keya_bool}' == 'True' Catenate SEPARATOR= \\ ${keya}
256 ... ELSE Catenate ${keya}
257 ${metricval}= Create Temporary Key Info ${keya} ${keyb}
258 @{lines}= Split to lines ${metricval}
259 ${mv_len}= Get Length ${lines}
260 ${mv_len}= Evaluate ${mv_len} - 1
261 ${found_line}= Get From List ${lines} ${mv_len}
262 @{split_line}= Split String ${found_line} ${SPACE}
263 ${metric_count}= Get From List ${split_line} 3
264 [Return] ${metric_count}
266 Form Portstats Query Pattern
267 [Arguments] ${metric} ${node} ${port} ${attribute}
268 [Documentation] Used for geneating openflow metrics Queries for Cassandra.
269 ${pattern}= Concatenate the String ${attribute} .
270 ${pattern}= Concatenate the String ${pattern} ${metric}
271 ${pattern}= Concatenate the String ${pattern} .
272 ${pattern}= Concatenate the String ${pattern} ${node}
273 ${pattern}= Concatenate the String ${pattern} .
274 ${pattern}= Concatenate the String ${pattern} Node_${node}
275 ${pattern}= Concatenate the String ${pattern} .
276 ${pattern}= Concatenate the String ${pattern} NodeConnector_${node}:${port}
277 ${pattern}= Remove Space on String ${pattern}
280 Create Temporary Key Info
281 [Arguments] ${pattern} ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s ${val_table}=metricval
282 [Documentation] Return rows matching keya and keyb
283 ${output}= Run Command On Remote System ${ODL_SYSTEM_IP} cat ${CASSANDRA_DB_PATH}${val_table}|grep "${pattern}"
286 Verify Metric Val File
287 [Documentation] Returns Value for metric matching particular keya,keyb
288 @{metricval}= Read File and Return Split Lines ${CASSANDRA_DB_PATH}${temp_metric_val}
289 ${mv_len}= Get Length ${metricval}
290 ${mv_len}= Evaluate ${mv_len} - 1
291 ${found_line}= Get From List ${metricval} ${mv_len}
292 @{split_line}= Split String ${found_line} ${SPACE}
293 ${metric_count}= Get From List ${split_line} 3
294 [Return] ${metric_count}
296 Verify Metric log File
297 [Arguments] ${metric_log} ${pattern}
298 [Documentation] Returns Value for lines in Metriclog matching the pattern
299 ${contents}= Grep From File ${CASSANDRA_DB_PATH}${temp_metric_val} ${pattern}
303 [Arguments] ${file} ${pattern}
304 [Documentation] Use cat to grep from the file and return the output
305 ${output}= Run Command On Remote System ${ODL_SYSTEM_IP} cat ${file} | ${pattern}
309 [Arguments] ${pattern} ${file}
310 [Documentation] Return list element which has the particular pattern.
311 ${metric_grep}= Grep From File ${TSDR_PATH}/tsdrKeyCache.txt ${pattern}
312 @{split_line}= Split String ${metric_grep} |
313 ${keypath}= Get From List ${split_line} 0
314 [Return] @{split_line}
317 [Arguments] ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s ${key_table}=metricpath ${val_table}=metricval
318 [Documentation] Copy TSDR files to external File system for text processing.
319 Log Attempting to truncate tables in Cassandra
320 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
321 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
322 Write export JAVA_HOME=/usr
323 Write sudo ${CASSANDRA_CLIENT}/cqlsh
325 Write COPY tsdr.${key_table} TO '${CASSANDRA_DB_PATH}${key_table}' WITH DELIMITER = ' ';
327 Write COPY tsdr.${val_table} TO '${CASSANDRA_DB_PATH}${val_table}' WITH DELIMITER = ' ';
332 Issue Cassandra Query
333 [Arguments] ${query} ${output} ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s
334 [Documentation] Issue query in cqlsh and match it with output which is passed as a argument
335 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
336 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
337 Write export JAVA_HOME=/usr
338 Write ${CASSANDRA_CLIENT}/cqlsh
340 ${query_output}= Write ${query}
341 ${query_output}= Read Until cqlsh>
342 ${str_output}= Convert To String ${output}
343 Should Contain ${query_output} ${str_output}
348 [Arguments] ${query} ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s
349 [Documentation] Issue query in cqlsh and match it with output which is passed as a argument
350 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
351 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
352 Write export JAVA_HOME=/usr
353 Write ${CASSANDRA_CLIENT}/cqlsh
355 ${query_output}= Write ${query}
356 ${query_output}= Read Until cqlsh>
359 [Return] ${query_output}
361 Read File and Return Split Lines
362 [Arguments] ${filename}
363 [Documentation] Reads the file and returns each line as list
364 ${contents}= Run Command On Remote System ${ODL_SYSTEM_IP} cat ${filename}
365 @{lines}= Split to lines ${contents}
369 [Arguments] ${query} ${xpath}
370 [Documentation] Parse the xml output and returns it.
371 ${sid}= RequestsLibrary.Create_Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} headers=${SEND_ACCEPT_XML_HEADERS} auth=${AUTH}
372 ${resp}= RequestsLibrary.Get Request session ${query} headers=${SEND_ACCEPT_XML_HEADERS}
373 ${resp_xml}= Parse XML ${resp.content}
374 ${id1}= Get Element Text ${resp_xml} ${xpath}
378 Return all XML matches
379 [Arguments] ${query} ${xpath}
380 [Documentation] Returns all the values from xpath
381 ${sid}= RequestsLibrary.Create_Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} headers=${SEND_ACCEPT_XML_HEADERS} auth=${AUTH}
382 ${resp}= RequestsLibrary.Get Request session ${query} headers=${SEND_ACCEPT_XML_HEADERS}
383 ${resp_xml}= Parse XML ${resp.content}
384 @{id1}= Get Elements Texts ${resp_xml} ${xpath}
388 Compare Tsdr XML Metrics
389 [Arguments] ${xml} ${tsdr} ${deviation}=10
390 [Documentation] Compares xml metrics from openflow plugin with TSDR metric values
391 ${val_max}= Evaluate ${xml}*${deviation}/100
392 ${val_diff}= Evaluate ${tsdr} - ${xml}
393 ${find_negative}= Evaluate ${val_diff} < 0
394 ${val_diff}= Run Keyword If '${find_negative}' == 'True' Evaluate ${val_diff}*-1
395 ... ELSE Evaluate ${val_diff}*1
396 Should Be True ${val_diff} <= ${val_max}
399 [Arguments] ${facility} ${level} ${MESSAGE}
400 [Documentation] Uses syslogd to generate syslogs
401 Run Command On Remote System ${ODL_SYSTEM_IP} logger -p ${facility}.${level} -n 127.0.0.1 -u 514 ${MESSAGE}
403 Verify Metric Val File For Syslog
404 [Documentation] Returns Value for metric matching particular keya,keyb
405 @{metricval}= Read File and Return Split Lines ${CASSANDRA_DB_PATH}${temp_metric_val}
406 [Return] ${metricval}
408 Verify the Metrics Syslog on Cassandra Client
409 [Arguments] ${pattern}
410 [Documentation] Getting the keya and keyb for a particular syslog agent and create a temporary file from metriclog
411 @{metric_row}= Find Metricval Keys ${pattern} metricpath
412 ${keya}= Get From List ${metric_row} 1
413 ${keyb}= Get From List ${metric_row} 2
414 ${keya_bool}= Evaluate ${keya} < 0
415 ${keya}= Run Keyword If '${keya_bool}' == 'True' Catenate SEPARATOR= \\ ${keya}
416 ... ELSE Catenate ${keya}
417 ${metric_log}= Create Temporary Key Info ${keya} ${keyb} val_table=metriclog
418 [Return] ${metric_log}
420 Iterating over metricpath
421 [Documentation] Used to traverse over metricpath file and traverse over metricpath file and get the keys
422 @{mp_lines}= Read File and Return Split Lines ${CASSANDRA_DB_PATH}${metric_path}
423 : FOR ${line} IN @{mp_lines}
424 \ @{split_line}= Split String ${line} ${SPACE}
425 \ ${keya}= Get From List ${split_line} 1
426 \ ${keyb}= Get From List ${split_line} 2
427 \ Iterating over metricval ${keya} ${keyb}
429 Iterating over metricval
430 [Arguments] ${keya} ${keyb}
431 [Documentation] Used to traverse over metricval file and check if keya and keyb are present.
432 ${mv_contents}= OperatingSystem.Get File ${CASSANDRA_DB_PATH}${metric_val}
433 Should Contain ${mv_contents} ${keya} ${keyb}
436 [Arguments] ${pattern}
437 [Documentation] Count the number of rows in metricpath and compare with the pattern.
438 ${query_output}= Count Cassandra rows select count(*) from tsdr.metricpath;
439 Should Match Regexp ${query_output} ${pattern}
442 [Arguments] ${pattern} ${TYPE}
443 [Documentation] Count the number of rows in HSQLDB with Metric ${TYPE}
444 ${output}= Issue Command On Karaf Console tsdr:list ${TYPE}
445 Should Match Regexp ${output} ${pattern}
448 [Arguments] ${pattern}
449 [Documentation] Count the number of rows in metricval table and compare with the pattern.
450 ${query_output}= Count Cassandra rows select count(*) from tsdr.metricval;
451 Should Match Regexp ${query_output} ${pattern}
454 [Arguments] ${pattern}
455 [Documentation] Count the number of rows in metriclog and compare with the pattern.
456 ${query_output}= Count Cassandra rows select count(*) from tsdr.metriclog;
457 Should Match Regexp ${query_output} ${pattern}
460 [Arguments] ${key} ${MESSAGE} ${syslog_severity}
461 [Documentation] Simulating FOR loop for generating syslogs for each syslog_severity
462 : FOR ${level} IN ZIP &{syslog_severity}
463 \ ${level_value}= Get From Dictionary ${syslog_severity} ${level}
464 \ Generate Syslog ${key} ${level} ${MESSAGE}
466 Severity Iterator For TSDR
467 [Arguments] ${key} ${facility_value} ${iterator_value} ${syslogs} ${MESSAGE} ${syslog_severity}
468 [Documentation] Simulating FOR loop for checking TSDR for each syslog_severity
469 ${iterator}= Evaluate ${iterator_value} * 8
470 : FOR ${level} IN ZIP &{syslog_severity}
471 \ ${severity_value}= Get From Dictionary ${syslog_severity} ${level}
472 \ ${fac_sev}= Evaluate ${facility_value} * 8 + ${severity_value}
473 \ Should Contain @{syslogs}[${iterator}] ${MESSAGE}
474 \ Should Contain @{syslogs}[${iterator}] <${fac_sev}>
475 \ ${iterator}= Evaluate ${iterator} + 1
477 Severity Iterator For Syslog HBase
478 [Arguments] ${message} ${value} &{syslog_severity}
479 [Documentation] Simulating FOR loop for checking HBASE for each syslog_severity
480 ${output}= Query the Data from HBaseClient scan 'SYSLOG'
481 Should Contain X Times ${output} ${message} 8
482 ${iterator}= Evaluate ${value} * 8
483 : FOR ${level} IN ZIP &{syslog_severity}
484 \ ${severity_value}= Get From Dictionary ${syslog_severity} ${level}
485 \ ${fac_sev}= Evaluate ${iterator} + ${severity_value}
486 \ Should Match ${output} *${fac_sev}>*
489 [Arguments] ${DC}= ${MN}= ${NID}= ${RK}= ${from}=0 ${until}=now
490 [Documentation] Issues TSDR Query and returns the list
491 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_QUERY}
492 ${resp}= RequestsLibrary.Get Request session /tsdr/metrics/query?tsdrkey="[NID=${NID}][DC=${DC}][MN=${MN}][RK=${RK}]"&from=${from}&until=${until} headers=${HEADERS_QUERY}
493 @{convert}= Parse Json ${resp.content}
498 [Arguments] ${DC}= ${MN}= ${NID}= ${RK}= ${from}=0 ${until}=now
499 ... ${datapts}=1000000
500 [Documentation] Issues TSDR Query and returns the list
501 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_QUERY}
502 ${resp}= RequestsLibrary.Get Request session /tsdr/nbi/render?target="[NID=${NID}][DC=${DC}][MN=${MN}][RK=${RK}]"&from=${from}&until=${until}&maxDataPoints=${datapts} headers=${HEADERS_QUERY}
503 @{convert}= Parse Json ${resp.content}
504 ${dict_convert}= Convert To Dictionary @{convert}
505 @{dict}= Get Dictionary Values ${dict_convert}
506 @{datapoints_list}= Convert to List @{dict}[0]
508 [Return] @{datapoints_list}
510 Extract PORTSTATS RecordKeys
511 [Arguments] ${Record_keys}
512 [Documentation] Dissect Record keys for Portstats
513 ${node_dict}= Get From List ${Record_keys} 0
514 ${nc_dict}= Get From List ${Record_keys} 1
515 ${NODE}= Get From Dictionary ${node_dict} keyValue
516 ${NC}= Get From Dictionary ${nc_dict} keyValue
517 ${rk_val}= Set Variable Node:${NODE},NodeConnector:${NC}
520 Extract QUEUESTATS RecordKeys
521 [Arguments] ${Record_keys}
522 [Documentation] Dissect Record keys for Queuestats
523 ${node_dict}= Get From List ${Record_keys} 0
524 ${connect_dict}= Get From List ${Record_keys} 1
525 ${queue_dict}= Get From List ${Record_keys} 2
526 ${NODE}= Get From Dictionary ${node_dict} keyValue
527 ${CONNECT}= Get From Dictionary ${connect_dict} keyValue
528 ${QUEUE}= Get From Dictionary ${queue_dict} keyValue
529 ${rk_val}= Set Variable Node:${NODE},NodeConnector:${CONNECT},Queue:${QUEUE}
532 Extract FLOWSTATS RecordKeys
533 [Arguments] ${Record_keys}
534 [Documentation] Dissect Record keys for Flowstats
535 ${node_dict}= Get From List ${Record_keys} 0
536 ${table_dict}= Get From List ${Record_keys} 1
537 ${flow_dict}= Get From List ${Record_keys} 2
538 ${NODE}= Get From Dictionary ${node_dict} keyValue
539 ${TABLE}= Get From Dictionary ${table_dict} keyValue
540 ${FLOW}= Get From Dictionary ${flow_dict} keyValue
541 ${rk_val}= Set Variable Node:${NODE},Table:${TABLE},Flow:${FLOW}
544 Extract FLOWTABLESTATS RecordKeys
545 [Arguments] ${Record_keys}
546 [Documentation] Dissect Record keys for Flowtablestats
547 ${node_dict}= Get From List ${Record_keys} 0
548 ${table_dict}= Get From List ${Record_keys} 1
549 ${NODE}= Get From Dictionary ${node_dict} keyValue
550 ${TABLE}= Get From Dictionary ${table_dict} keyValue
551 ${rk_val}= Set Variable Node:${NODE},Table:${TABLE}
554 Extract Row Values from TSDR Query
555 [Arguments] ${row_dict} ${tsdr_row} ${nbi_row} ${DATA_CATEGORY}
556 [Documentation] Extract the row values from query and generate it in DB format
557 ${nbi_value}= Get From List ${nbi_row} 0
558 ${nbi_time}= Get From List ${nbi_row} 1
559 ${MN}= Get From Dictionary ${row_dict} metricName
560 ${MV}= Get From Dictionary ${row_dict} metricValue
561 ${NID}= Get From Dictionary ${row_dict} nodeID
562 ${RK}= Get From Dictionary ${row_dict} recordKeys
563 ${time}= Get From Dictionary ${row_dict} timeStamp
564 ${DC}= Get From Dictionary ${row_dict} tsdrDataCategory
565 ${RK_VAL}= Run Keyword If '${DATA_CATEGORY}'=='PORTSTATS' Extract PORTSTATS RecordKeys ${RK}
566 ... ELSE IF '${DATA_CATEGORY}'=='FLOWSTATS' Extract FLOWSTATS RecordKeys ${RK}
567 ... ELSE IF '${DATA_CATEGORY}'=='FLOWTABLESTATS' Extract FLOWTABLESTATS RecordKeys ${RK}
568 ... ELSE IF '${DATA_CATEGORY}'=='QUEUESTATS' Extract QUEUESTATS RecordKeys ${RK}
569 ${epoch_time}= Convert Date ${time} epoch date_format=%a %b %d %H:%M:%S %Z %Y
570 ${epoch_time_int}= Convert To Integer ${epoch_time}
571 Should Match ${tsdr_row} *${NID}*
572 Should Match ${tsdr_row} *${DC}*
573 Should Match ${tsdr_row} *${MN}*
574 Should Match ${tsdr_row} *${RK_VAL}*
575 Should Match ${tsdr_row} *[${MV}]*
576 Should Match ${tsdr_row} *${epoch_time_int}*
577 Should Be Equal As Numbers ${nbi_time} ${epoch_time_int}
578 Should Be Equal As Numbers ${nbi_value} ${MV}
580 Evaluate Datasets Length
581 [Arguments] ${tsdr_lines} ${query_output} ${nbi_output}
582 [Documentation] Compare the outputs returned from all Data Stores
583 ${query_count}= Get Length ${query_output}
584 ${tsdr_count}= Get Length ${tsdr_lines}
585 ${nbi_count}= Get Length ${nbi_output}
586 Should Be Equal As Numbers ${query_count} ${tsdr_count}
587 Should Be Equal As Numbers ${nbi_count} ${tsdr_count}
589 Evaluate Datasets Value
590 [Arguments] ${tsdr_lines} ${query_output} ${nbi_output} ${TYPE}
591 [Documentation] Compare the outputs returned from all Data Stores
592 : FOR ${q_item} ${t_item} ${n_item} IN ZIP ${query_output} ${tsdr_lines}
594 \ ${query_row}= Extract Row Values from TSDR Query ${q_item} ${t_item} ${n_item} ${TYPE}
595 : FOR ${found_line} IN @{matching_list}
596 \ @{split_line}= Split String ${found_line} |
597 \ ${hex_name}= Get From List ${split_line} 2
598 \ ${if_desc}= Decode Bytes To String ${hex_name} HEX
599 \ Append To List ${ifdesc_list} ${if_desc}
600 [Return] @{ifdesc_list}
603 [Arguments] ${HOST}=127.0.0.1 ${community}=${SNMP_COMMUNITY}
604 [Documentation] Write SNMP Config File
605 Create File snmp.cfg credentials=[${HOST},${community}]
606 Append To File snmp.cfg \n
607 Move File snmp.cfg ${SNMP_PATH}
610 [Documentation] Brings up basic netflow setup .
611 Verify Feature Is Installed odl-tsdr-netflow-statistics-collector
612 Wait Until Keyword Succeeds 24x 10 sec Check Karaf Log Has Messages NetFlow Data Colletor Initialized
617 Collect Data from SNMP Agent
618 [Arguments] ${SNMP_IP}=127.0.0.1 ${SNMP_AGENT_COMM}=${SNMP_COMMUNITY}
619 [Documentation] Poll for SNMP Agent OID
620 ${snmpagentinfo} Create Dictionary ip-address=${SNMP_IP} community=${SNMP_AGENT_COMM}
621 ${snmpagentcreate} Create Dictionary input=${snmpagentinfo}
622 ${snmpagentcreate_json}= json.dumps ${snmpagentcreate}
623 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_QUERY}
624 ${resp}= RequestsLibrary.Post Request session /restconf/operations/snmp:get-interfaces data=${snmpagentcreate_json}
625 ${convert}= To Json ${resp.content}
626 @{dict1}= Get Dictionary Keys ${convert}
627 ${dict1_0}= Get From List ${dict1} 0
628 ${dict1_val}= Get From Dictionary ${convert} ${dict1_0}
629 @{ifEntry}= Get From Dictionary ${dict1_val} ifEntry
630 @{SNMP_ENTRY}= Create List
631 @{SNMP_VALUES}= Create List
632 : FOR ${int} IN @{ifEntry}
633 \ ${ifindex}= Get From Dictionary ${int} ifIndex
634 \ ${ifOutDiscards}= Get From Dictionary ${int} ifOutDiscards
635 \ ${ifInDiscards}= Get From Dictionary ${int} ifInDiscards
636 \ ${ifType}= Get From Dictionary ${int} ifType
637 \ ${ifInOctets}= Get From Dictionary ${int} ifInOctets
638 \ ${ifSpeed}= Get From Dictionary ${int} ifSpeed
639 \ ${ifOutQLen}= Get From Dictionary ${int} ifOutQLen
640 \ ${ifOutErrors}= Get From Dictionary ${int} ifOutErrors
641 \ ${ifPhysAddress}= Get From Dictionary ${int} ifPhysAddress
642 \ ${ifInUcastPkts}= Get From Dictionary ${int} ifInUcastPkts
643 \ ${ifOutNUcastPkts}= Get From Dictionary ${int} ifOutNUcastPkts
644 \ ${ifInErrors}= Get From Dictionary ${int} ifInErrors
645 \ ${ifOutOctets}= Get From Dictionary ${int} ifOutOctets
646 \ ${ifAdminStatus1}= Get From Dictionary ${int} ifAdminStatus
647 \ ${ifAdminStatus}= Get From Dictionary ${OPER_STATUS} ${ifAdminStatus1}
648 \ ${ifInUnknownProtos}= Get From Dictionary ${int} ifInUnknownProtos
649 \ ${ifOutUcastPkts}= Get From Dictionary ${int} ifOutUcastPkts
650 \ ${ifInNUcastPkts}= Get From Dictionary ${int} ifInNUcastPkts
651 \ ${ifMtu}= Get From Dictionary ${int} ifMtu
652 \ ${ifOperStatus1}= Get From Dictionary ${int} ifOperStatus
653 \ ${ifOperStatus}= Get From Dictionary ${OPER_STATUS} ${ifOperStatus1}
654 \ Append To List ${SNMP_ENTRY} grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOutDiscards | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutDiscards
655 \ Append To List ${SNMP_VALUES} ${ifOutDiscards}
656 \ Append To List ${SNMP_ENTRY} grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfInDiscards | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInDiscards
657 \ Append To List ${SNMP_VALUES} ${ifInDiscards}
658 \ Append To List ${SNMP_ENTRY} grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfInOctets | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInOctets
659 \ Append To List ${SNMP_VALUES} ${ifInOctets}
660 \ Append To List ${SNMP_ENTRY} grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOutQLen | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutQLen
661 \ Append To List ${SNMP_VALUES} ${ifOutQLen}
662 \ Append To List ${SNMP_ENTRY} grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOutErrors | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutErrors
663 \ Append To List ${SNMP_VALUES} ${ifOutErrors}
664 \ Append To List ${SNMP_ENTRY} grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfInUcastPkts | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInUcastPkts
665 \ Append To List ${SNMP_VALUES} ${ifInUcastPkts}
666 \ Append To List ${SNMP_ENTRY} grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOutNUcastPkts | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutNUcastPkts
667 \ Append To List ${SNMP_VALUES} ${ifOutNUcastPkts}
668 \ Append To List ${SNMP_ENTRY} grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfInErrors | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInErrors
669 \ Append To List ${SNMP_VALUES} ${ifInErrors}
670 \ Append To List ${SNMP_ENTRY} grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOutOctets | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutOctets
671 \ Append To List ${SNMP_VALUES} ${ifOutOctets}
672 \ Append To List ${SNMP_ENTRY} grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfAdminStatus | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfAdminStatus
673 \ Append To List ${SNMP_VALUES} ${ifAdminStatus}
674 \ Append To List ${SNMP_ENTRY} grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfInUnknownProtos | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInUnknownProtos
675 \ Append To List ${SNMP_VALUES} ${ifInUnknownProtos}
676 \ Append To List ${SNMP_ENTRY} grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOutUcastPkts | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutUcastPkts
677 \ Append To List ${SNMP_VALUES} ${ifOutUcastPkts}
678 \ Append To List ${SNMP_ENTRY} grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfInNUcastPkts | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInNUcastPkts
679 \ Append To List ${SNMP_VALUES} ${ifInNUcastPkts}
680 \ Append To List ${SNMP_ENTRY} grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOperStatus | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOperStatus
681 \ Append To List ${SNMP_VALUES} ${ifOperStatus}
682 [Return] ${SNMP_ENTRY} ${SNMP_VALUES}