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=30s
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] ${pattern}
61 [Documentation] Iperf between h1 and h2 and check Hbase
62 Switch Connection ${mininet_conn_id1}
65 ${query_output}= Query the Data from HBaseClient count 'NETFLOW'
66 Should Match Regexp ${query_output} ${pattern}
68 Iperf All Hosts Cassandra
69 [Arguments] ${pattern}
70 [Documentation] Iperf between h1 and h2 and check Cassandra
71 Switch Connection ${mininet_conn_id1}
74 ${query_output}= Count Cassandra rows select count(*) from tsdr.metriclog;
75 Should Match Regexp ${query_output} ${pattern}
78 [Documentation] Cleanup/Shutdown work that should be done at the completion of all
80 Switch Connection ${mininet_conn_id1}
83 Read Until ${DEFAULT_LINUX_PROMPT}
87 [Arguments] ${HOST}=127.0.0.1 ${purge_enabled}=true ${purge_time}=00:00:00 ${purge_interval}=1400 ${retention}=0
88 [Documentation] Write Purge file and copy it to directory.127.0.0.1 refers local controller
89 Create File purge.cfg \#TSDR Project Configuration file
90 Append To File purge.cfg \n
91 Append To File purge.cfg host=${HOST}
92 Append To File purge.cfg \n
93 Append To File purge.cfg data_purge_enabled=${purge_enabled}
94 Append To File purge.cfg \n
95 Append To File purge.cfg data_purge_time=${purge_time}
96 Append To File purge.cfg \n
97 Append To File purge.cfg data_purge_interval_in_minutes=${purge_interval}
98 Append To File purge.cfg \n
99 Append To File purge.cfg retention_time_in_hours=${retention}
100 Append To File purge.cfg \n
101 Move File purge.cfg ${PURGE_PATH}
103 Initialize the HBase for TSDR
104 [Documentation] Install and initialize the tsdr tables on HBase Server
105 ${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
107 ${hbase_process}= Run Command On Remote System ${ODL_SYSTEM_IP} ps -ef | grep HMaster
110 Stop the HBase Server
111 [Documentation] Stop the HBase server
112 ${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
115 Configure the Queue on Switch
116 [Arguments] ${queue_interface} ${user}=${TOOLS_SYSTEM_USER}
117 [Documentation] Configure the 2 queues on specified openvswitch interface
118 Log Configure the queue on ${queue_interface}
119 ${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
122 Query the Data from HBaseClient
123 [Arguments] ${query} ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s
124 [Documentation] Execute the HBase Query and return the result
125 Log Attempting to execute ${query} on ${remote} via HbaseClient
126 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
127 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
128 Write export JAVA_HOME=/usr
129 Write ${HBASE_CLIENT}/hbase shell
130 Read Until hbase(main):001:0>
132 ${output}= Read Until hbase(main):
135 Comment ${output}= Read Until ${DEFAULT_LINUX_PROMPT}
139 Verify the Metric is Collected?
140 [Arguments] ${tsdr_cmd} ${metric} ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s
141 [Documentation] Verify the ${tsdr_cmd} output contains ${metric}
142 ${output}= Issue Command On Karaf Console ${tsdr_cmd} ${remote} ${KARAF_SHELL_PORT} ${prompt_timeout}
143 Should Contain ${output} ${metric}
146 [Arguments] ${left_str} ${right_str} ${connector}
147 [Documentation] Prepare the Hbase Filter from Tsdr List output
148 ${left_str}= Remove Space on String ${left_str}
149 ${right_str}= Remove Space on String ${right_str} 1
150 ${x}= Run Keyword If '${left_str}' == 'MetricID' Catenate ${SPACE} _
151 ... ELSE IF '${left_str}' == 'ObjectKeys' Catenate ${right_str} _
152 ... ELSE IF '${left_str}' == 'TimeStamp' Get Epoch Time ${right_str}
153 ... ELSE Catenate ${SPACE}
156 Create the Hbase table row
157 [Arguments] ${tsdr_line} ${metrics}
158 [Documentation] Create the Hbase table row from tsdr:list
159 @{words}= Split String ${tsdr_line} |
160 : FOR ${li} IN @{words}
161 \ ${key}= Fetch From Left ${li} =
162 \ ${value}= Fetch From Right ${li} =
163 \ ${each_value}= Prepare HBase Filter ${key} ${value} _
164 \ ${final}= Concatenate the String ${final} ${each_value}
165 ${query}= Concatenate the String ${metrics} ${final}
166 ${query}= Remove Space on String ${query}
169 Initialize Cassandra Tables
170 [Arguments] ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s ${key_table}=metricpath ${val_table}=metricval
171 [Documentation] Truncate Existing tables in Cassandra to Start it fresh.
172 Log Attempting to truncate tables in Cassandra
173 Run Command On Remote System ${ODL_SYSTEM_IP} rm -rf ${CASSANDRA_DB_PATH}${key_table}
174 Run Command On Remote System ${ODL_SYSTEM_IP} rm -rf ${CASSANDRA_DB_PATH}${val_table}
175 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
176 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
177 Write export JAVA_HOME=/usr
178 Write ${CASSANDRA_CLIENT}/cqlsh
180 Write TRUNCATE tsdr.${key_table} ;
182 Write TRUNCATE tsdr.${val_table} ;
187 Initialize Cassandra Tables Metricval
188 [Arguments] ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s ${key_table}=metricpath ${val_table}=metricval
189 [Documentation] Truncate Existing tables in Cassandra to Start it fresh
190 Log Attempting to truncate tables in Cassandra
191 Run Command On Remote System ${ODL_SYSTEM_IP} rm -rf ${CASSANDRA_DB_PATH}${key_table}
192 Run Command On Remote System ${ODL_SYSTEM_IP} rm -rf ${CASSANDRA_DB_PATH}${val_table}
193 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
194 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
195 Write export JAVA_HOME=/usr
196 Write ${CASSANDRA_CLIENT}/cqlsh
198 Write TRUNCATE tsdr.${val_table} ;
203 Query Metrics on H2 Datastore
204 [Arguments] ${category} ${attribute} ${nodeid}=openflow:1
205 [Documentation] Generate the JDBC query for H2 Datastore
206 ${h2_query}= Concatenate the String jdbc:query metric "select * from Metric where MetricCategory= '${category}' and
207 ${h2_query}= Concatenate the String ${h2_query} MetricName = '${attribute}' and NODEID = '${nodeid}' order by ID desc limit 5"
208 ${output}= Issue Command On Karaf Console ${h2_query} ${ODL_SYSTEM_IP} ${KARAF_SHELL_PORT} 30
212 [Arguments] ${table} ${filter} ${metric}
213 [Documentation] Scan the Hbase Table with Filter
214 ${hbase_query}= Concatenate the String scan '${table}'
215 ${hbase_query}= Concatenate the String ${hbase_query} ,{ FILTER =>\"(RowFilter(=,
216 ${hbase_query}= Concatenate the String ${hbase_query} 'regexstring:${filter}*\')) AND (RowFilter(=,
217 ${hbase_query}= Concatenate the String ${hbase_query} 'regexstring:MN=${metric}*\'))\",LIMIT=>10}
218 [Return] ${hbase_query}
221 [Arguments] ${tsdr_line}
222 [Documentation] Get Metric Value from tsdr:list
223 ${value}= Fetch From Right ${tsdr_line} |
224 ${value}= Replace String ${value} MetricValue value
225 ${value}= Replace String ${value} [m ${EMPTY}
226 ${value}= Replace String ${value} = \=
227 ${value}= Remove Space on String ${value}
228 ${value}= Convert to String ${value}
231 Verify the Metrics Attributes on Hbase Client
232 [Arguments] ${attribute} ${rowfilter} ${table}=PortStats
233 [Documentation] Verification on Metrics attributes on Hbase Client
234 ${query}= Generate HBase Query ${table} ${rowfilter} ${attribute}
235 ${out}= Query the Data from HBaseClient ${query}
236 Should Match Regexp ${out} (?mui)value
238 Verify the Metrics Attributes on Cassandra Client
239 [Arguments] ${pattern}
240 [Documentation] Verification on Metrics attributes on Cassandra Client
241 @{metric_row}= Find Metricval Keys ${pattern} metricpath
242 ${keya}= Get From List ${metric_row} 1
243 ${keyb}= Get From List ${metric_row} 2
244 ${keya_bool}= Evaluate ${keya} < 0
245 ${keya}= Run Keyword If '${keya_bool}' == 'True' Catenate SEPARATOR= \\ ${keya}
246 ... ELSE Catenate ${keya}
247 Create Temporary Key Info ${keya} ${keyb}
248 ${metric_value}= Verify Metric Val File
249 [Return] ${metric_value}
251 Form Portstats Query Pattern
252 [Arguments] ${metric} ${node} ${port} ${attribute}
253 [Documentation] Used for geneating openflow metrics Queries for Cassandra.
254 ${pattern}= Concatenate the String ${attribute} .
255 ${pattern}= Concatenate the String ${pattern} ${metric}
256 ${pattern}= Concatenate the String ${pattern} .
257 ${pattern}= Concatenate the String ${pattern} ${node}
258 ${pattern}= Concatenate the String ${pattern} .
259 ${pattern}= Concatenate the String ${pattern} Node_${node}
260 ${pattern}= Concatenate the String ${pattern} .
261 ${pattern}= Concatenate the String ${pattern} NodeConnector_${node}:${port}
262 ${pattern}= Remove Space on String ${pattern}
265 Create Temporary Key Info
266 [Arguments] ${pattern} ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s ${val_table}=metricval
267 [Documentation] Creates a temporary File with matching keya,keyb values.
268 Log Removing existing file
269 Run Command On Remote System ${ODL_SYSTEM_IP} rm -rf ${CASSANDRA_DB_PATH}${temp_metric_val}
270 Run Command On Remote System ${ODL_SYSTEM_IP} cat ${CASSANDRA_DB_PATH}${val_table}|grep "${pattern}" > ${CASSANDRA_DB_PATH}${temp_metric_val}
272 Verify Metric Val File
273 [Documentation] Returns Value for metric matching particular keya,keyb
274 @{metricval}= Read File and Return Split Lines ${CASSANDRA_DB_PATH}${temp_metric_val}
275 ${mv_len}= Get Length ${metricval}
276 ${mv_len}= Evaluate ${mv_len} - 1
277 ${found_line}= Get From List ${metricval} ${mv_len}
278 @{split_line}= Split String ${found_line} ${SPACE}
279 ${metric_count}= Get From List ${split_line} 3
280 [Return] ${metric_count}
282 Verify Metric log File
283 [Arguments] ${pattern}
284 [Documentation] Returns Value for lines in Metriclog file matching the pattern
285 ${contents}= Grep File ${CASSANDRA_DB_PATH}${temp_metric_val} ${pattern}
289 [Arguments] ${pattern} ${file}
290 [Documentation] Return list element which has the particular pattern.
291 ${db_grep}= Grep File ${CASSANDRA_DB_PATH}${file} ${pattern}
292 ${metric_grep}= Grep File ${TSDR_PATH}/tsdrKeyCache.txt ${pattern}
293 @{split_line}= Split String ${metric_grep} |
294 ${keypath}= Get From List ${split_line} 0
295 Should Contain ${db_grep} ${keypath}
296 [Return] @{split_line}
299 [Arguments] ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s ${key_table}=metricpath ${val_table}=metricval
300 [Documentation] Copy TSDR files to external File system for text processing.
301 Log Attempting to truncate tables in Cassandra
302 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
303 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
304 Write export JAVA_HOME=/usr
305 Write ${CASSANDRA_CLIENT}/cqlsh
307 Write COPY tsdr.${key_table} TO '${CASSANDRA_DB_PATH}${key_table}' WITH DELIMITER = ' ';
309 Write COPY tsdr.${val_table} TO '${CASSANDRA_DB_PATH}${val_table}' WITH DELIMITER = ' ';
314 Issue Cassandra Query
315 [Arguments] ${query} ${output} ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s
316 [Documentation] Issue query in cqlsh and match it with output which is passed as a argument
317 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
318 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
319 Write export JAVA_HOME=/usr
320 Write ${CASSANDRA_CLIENT}/cqlsh
322 ${query_output}= Write ${query}
323 ${query_output}= Read Until cqlsh>
324 ${str_output}= Convert To String ${output}
325 Should Contain ${query_output} ${str_output}
330 [Arguments] ${query} ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s
331 [Documentation] Issue query in cqlsh and match it with output which is passed as a argument
332 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
333 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
334 Write export JAVA_HOME=/usr
335 Write ${CASSANDRA_CLIENT}/cqlsh
337 ${query_output}= Write ${query}
338 ${query_output}= Read Until cqlsh>
341 [Return] ${query_output}
343 Read File and Return Split Lines
344 [Arguments] ${filename}
345 [Documentation] Reads the file and returns each line as list
346 ${contents}= OperatingSystem.Get File ${filename}
347 @{lines}= Split to lines ${contents}
351 [Arguments] ${query} ${xpath}
352 [Documentation] Parse the xml output and returns it.
353 ${sid}= RequestsLibrary.Create_Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} headers=${SEND_ACCEPT_XML_HEADERS} auth=${AUTH}
354 ${resp}= RequestsLibrary.Get Request session ${query} headers=${SEND_ACCEPT_XML_HEADERS}
355 ${resp_xml}= Parse XML ${resp.content}
356 ${id1}= Get Element Text ${resp_xml} ${xpath}
360 Return all XML matches
361 [Arguments] ${query} ${xpath}
362 [Documentation] Returns all the values from xpath
363 ${sid}= RequestsLibrary.Create_Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} headers=${SEND_ACCEPT_XML_HEADERS} auth=${AUTH}
364 ${resp}= RequestsLibrary.Get Request session ${query} headers=${SEND_ACCEPT_XML_HEADERS}
365 ${resp_xml}= Parse XML ${resp.content}
366 @{id1}= Get Elements Texts ${resp_xml} ${xpath}
370 Compare Tsdr XML Metrics
371 [Arguments] ${xml} ${tsdr} ${deviation}=10
372 [Documentation] Compares xml metrics from openflow plugin with TSDR metric values
373 ${val_max}= Evaluate ${xml}*${deviation}/100
374 ${val_diff}= Evaluate ${tsdr} - ${xml}
375 ${find_negative}= Evaluate ${val_diff} < 0
376 ${val_diff}= Run Keyword If '${find_negative}' == 'True' Evaluate ${val_diff}*-1
377 ... ELSE Evaluate ${val_diff}*1
378 Should Be True ${val_diff} <= ${val_max}
381 [Arguments] ${facility} ${level} ${MESSAGE}
382 [Documentation] Uses syslogd to generate syslogs
383 Run Command On Remote System ${ODL_SYSTEM_IP} logger -p ${facility}.${level} -n 127.0.0.1 -u 514 ${MESSAGE}
385 Verify Metric Val File For Syslog
386 [Documentation] Returns Value for metric matching particular keya,keyb
387 @{metricval}= Read File and Return Split Lines ${CASSANDRA_DB_PATH}${temp_metric_val}
388 [Return] ${metricval}
390 Verify the Metrics Syslog on Cassandra Client
391 [Arguments] ${pattern}
392 [Documentation] Getting the keya and keyb for a particular syslog agent and create a temporary file from metriclog
393 @{metric_row}= Find Metricval Keys ${pattern} metricpath
394 ${keya}= Get From List ${metric_row} 1
395 ${keyb}= Get From List ${metric_row} 2
396 ${keya_bool}= Evaluate ${keya} < 0
397 ${keya}= Run Keyword If '${keya_bool}' == 'True' Catenate SEPARATOR= \\ ${keya}
398 ... ELSE Catenate ${keya}
399 Create Temporary Key Info ${keya} ${keyb} val_table=${metric_log}
401 Iterating over metricpath
402 [Documentation] Used to traverse over metricpath file and traverse over metricpath file and get the keys
403 @{mp_lines}= Read File and Return Split Lines ${CASSANDRA_DB_PATH}${metric_path}
404 : FOR ${line} IN @{mp_lines}
405 \ @{split_line}= Split String ${line} ${SPACE}
406 \ ${keya}= Get From List ${split_line} 1
407 \ ${keyb}= Get From List ${split_line} 2
408 \ Iterating over metricval ${keya} ${keyb}
410 Iterating over metricval
411 [Arguments] ${keya} ${keyb}
412 [Documentation] Used to traverse over metricval file and check if keya and keyb are present.
413 ${mv_contents}= OperatingSystem.Get File ${CASSANDRA_DB_PATH}${metric_val}
414 Should Contain ${mv_contents} ${keya} ${keyb}
417 [Arguments] ${pattern}
418 [Documentation] Count the number of rows in metricpath and compare with the pattern.
419 ${query_output}= Count Cassandra rows select count(*) from tsdr.metricpath;
420 Should Match Regexp ${query_output} ${pattern}
423 [Arguments] ${pattern} ${TYPE}
424 [Documentation] Count the number of rows in HSQLDB with Metric ${TYPE}
425 ${output}= Issue Command On Karaf Console tsdr:list ${TYPE}
426 Should Match Regexp ${output} ${pattern}
429 [Arguments] ${pattern}
430 [Documentation] Count the number of rows in metricval table and compare with the pattern.
431 ${query_output}= Count Cassandra rows select count(*) from tsdr.metricval;
432 Should Match Regexp ${query_output} ${pattern}
435 [Arguments] ${pattern}
436 [Documentation] Count the number of rows in metriclog and compare with the pattern.
437 ${query_output}= Count Cassandra rows select count(*) from tsdr.metriclog;
438 Should Match Regexp ${query_output} ${pattern}
441 [Arguments] ${key} ${MESSAGE} ${syslog_severity}
442 [Documentation] Simulating FOR loop for generating syslogs for each syslog_severity
443 : FOR ${level} IN ZIP &{syslog_severity}
444 \ ${level_value}= Get From Dictionary ${syslog_severity} ${level}
445 \ Generate Syslog ${key} ${level} ${MESSAGE}
447 Severity Iterator For TSDR
448 [Arguments] ${key} ${facility_value} ${iterator_value} ${syslogs} ${MESSAGE} ${syslog_severity}
449 [Documentation] Simulating FOR loop for checking TSDR for each syslog_severity
450 ${iterator}= Evaluate ${iterator_value} * 8
451 : FOR ${level} IN ZIP &{syslog_severity}
452 \ ${severity_value}= Get From Dictionary ${syslog_severity} ${level}
453 \ ${fac_sev}= Evaluate ${facility_value} * 8 + ${severity_value}
454 \ Should Contain @{syslogs}[${iterator}] ${MESSAGE}
455 \ Should Contain @{syslogs}[${iterator}] <${fac_sev}>
456 \ ${iterator}= Evaluate ${iterator} + 1
458 Severity Iterator For Syslog HBase
459 [Arguments] ${message} ${value} &{syslog_severity}
460 [Documentation] Simulating FOR loop for checking HBASE for each syslog_severity
461 ${output}= Query the Data from HBaseClient scan 'SysLog'
462 Should Contain X Times ${output} ${message} 8
463 ${iterator}= Evaluate ${value} * 8
464 : FOR ${level} IN ZIP &{syslog_severity}
465 \ ${severity_value}= Get From Dictionary ${syslog_severity} ${level}
466 \ ${fac_sev}= Evaluate ${iterator} + ${severity_value}
467 \ Should Match ${output} *${fac_sev}>*
470 [Arguments] ${DC}= ${MN}= ${NID}= ${RK}= ${from}=0 ${until}=now
471 [Documentation] Issues TSDR Query and returns the list
472 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_QUERY}
473 ${resp}= RequestsLibrary.Get Request session /tsdr/metrics/query?tsdrkey="[NID=${NID}][DC=${DC}][MN=${MN}][RK=${RK}]"&from=${from}&until=${until} headers=${HEADERS_QUERY}
474 @{convert}= Parse Json ${resp.content}
479 [Arguments] ${DC}= ${MN}= ${NID}= ${RK}= ${from}=0 ${until}=now
480 ... ${datapts}=1000000
481 [Documentation] Issues TSDR Query and returns the list
482 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_QUERY}
483 ${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}
484 @{convert}= Parse Json ${resp.content}
485 ${dict_convert}= Convert To Dictionary @{convert}
486 @{dict}= Get Dictionary Values ${dict_convert}
487 @{datapoints_list}= Convert to List @{dict}[0]
489 [Return] @{datapoints_list}
491 Extract PORTSTATS RecordKeys
492 [Arguments] ${Record_keys}
493 [Documentation] Dissect Record keys for Portstats
494 ${node_dict}= Get From List ${Record_keys} 0
495 ${nc_dict}= Get From List ${Record_keys} 1
496 ${NODE}= Get From Dictionary ${node_dict} keyValue
497 ${NC}= Get From Dictionary ${nc_dict} keyValue
498 ${rk_val}= Set Variable Node:${NODE},NodeConnector:${NC}
501 Extract QUEUESTATS RecordKeys
502 [Arguments] ${Record_keys}
503 [Documentation] Dissect Record keys for Queuestats
504 ${node_dict}= Get From List ${Record_keys} 0
505 ${connect_dict}= Get From List ${Record_keys} 1
506 ${queue_dict}= Get From List ${Record_keys} 2
507 ${NODE}= Get From Dictionary ${node_dict} keyValue
508 ${CONNECT}= Get From Dictionary ${connect_dict} keyValue
509 ${QUEUE}= Get From Dictionary ${queue_dict} keyValue
510 ${rk_val}= Set Variable Node:${NODE},NodeConnector:${CONNECT},Queue:${QUEUE}
513 Extract FLOWSTATS RecordKeys
514 [Arguments] ${Record_keys}
515 [Documentation] Dissect Record keys for Flowstats
516 ${node_dict}= Get From List ${Record_keys} 0
517 ${table_dict}= Get From List ${Record_keys} 1
518 ${flow_dict}= Get From List ${Record_keys} 2
519 ${NODE}= Get From Dictionary ${node_dict} keyValue
520 ${TABLE}= Get From Dictionary ${table_dict} keyValue
521 ${FLOW}= Get From Dictionary ${flow_dict} keyValue
522 ${rk_val}= Set Variable Node:${NODE},Table:${TABLE},Flow:${FLOW}
525 Extract FLOWTABLESTATS RecordKeys
526 [Arguments] ${Record_keys}
527 [Documentation] Dissect Record keys for Flowtablestats
528 ${node_dict}= Get From List ${Record_keys} 0
529 ${table_dict}= Get From List ${Record_keys} 1
530 ${NODE}= Get From Dictionary ${node_dict} keyValue
531 ${TABLE}= Get From Dictionary ${table_dict} keyValue
532 ${rk_val}= Set Variable Node:${NODE},Table:${TABLE}
535 Extract Row Values from TSDR Query
536 [Arguments] ${row_dict} ${tsdr_row} ${nbi_row} ${DATA_CATEGORY}
537 [Documentation] Extract the row values from query and generate it in DB format
538 ${nbi_value}= Get From List ${nbi_row} 0
539 ${nbi_time}= Get From List ${nbi_row} 1
540 ${MN}= Get From Dictionary ${row_dict} metricName
541 ${MV}= Get From Dictionary ${row_dict} metricValue
542 ${NID}= Get From Dictionary ${row_dict} nodeID
543 ${RK}= Get From Dictionary ${row_dict} recordKeys
544 ${time}= Get From Dictionary ${row_dict} timeStamp
545 ${DC}= Get From Dictionary ${row_dict} tsdrDataCategory
546 ${RK_VAL}= Run Keyword If '${DATA_CATEGORY}'=='PORTSTATS' Extract PORTSTATS RecordKeys ${RK}
547 ... ELSE IF '${DATA_CATEGORY}'=='FLOWSTATS' Extract FLOWSTATS RecordKeys ${RK}
548 ... ELSE IF '${DATA_CATEGORY}'=='FLOWTABLESTATS' Extract FLOWTABLESTATS RecordKeys ${RK}
549 ... ELSE IF '${DATA_CATEGORY}'=='QUEUESTATS' Extract QUEUESTATS RecordKeys ${RK}
550 ${epoch_time}= Convert Date ${time} epoch date_format=%a %b %d %H:%M:%S %Z %Y
551 ${epoch_time_int}= Convert To Integer ${epoch_time}
552 LOG [NID=${NID}][DC=${DC}][MN=${MN}][${RK_VAL}][TS=${epoch_time_int}][${MV}]
553 Should Match ${tsdr_row} *${NID}*
554 Should Match ${tsdr_row} *${DC}*
555 Should Match ${tsdr_row} *${MN}*
556 Should Match ${tsdr_row} *${RK_VAL}*
557 Should Match ${tsdr_row} *[${MV}]*
558 Should Match ${tsdr_row} *${epoch_time_int}*
559 Should Be Equal As Numbers ${nbi_time} ${epoch_time_int}
560 Should Be Equal As Numbers ${nbi_value} ${MV}
562 Evaluate Datasets Length
563 [Arguments] ${tsdr_lines} ${query_output} ${nbi_output}
564 [Documentation] Compare the outputs returned from all Data Stores
565 ${query_count}= Get Length ${query_output}
566 ${tsdr_count}= Get Length ${tsdr_lines}
567 ${nbi_count}= Get Length ${nbi_output}
568 Should Be Equal As Numbers ${query_count} ${tsdr_count}
569 Should Be Equal As Numbers ${nbi_count} ${tsdr_count}
571 Evaluate Datasets Value
572 [Arguments] ${tsdr_lines} ${query_output} ${nbi_output} ${TYPE}
573 [Documentation] Compare the outputs returned from all Data Stores
574 : FOR ${q_item} ${t_item} ${n_item} IN ZIP ${query_output} ${tsdr_lines}
576 \ ${query_row}= Extract Row Values from TSDR Query ${q_item} ${t_item} ${n_item} ${TYPE}
577 : FOR ${found_line} IN @{matching_list}
578 \ @{split_line}= Split String ${found_line} |
579 \ ${hex_name}= Get From List ${split_line} 2
580 \ ${if_desc}= Decode Bytes To String ${hex_name} HEX
581 \ Append To List ${ifdesc_list} ${if_desc}
582 [Return] @{ifdesc_list}
585 [Arguments] ${HOST}=127.0.0.1 ${community}=${SNMP_COMMUNITY}
586 [Documentation] Write SNMP Config File
587 Create File snmp.cfg credentials=[${HOST},${community}]
588 Append To File snmp.cfg \n
589 Move File snmp.cfg ${SNMP_PATH}
591 Collect Data from SNMP Agent
592 [Arguments] ${SNMP_IP}=127.0.0.1 ${SNMP_AGENT_COMM}=${SNMP_COMMUNITY}
593 [Documentation] Poll for SNMP Agent OID
594 ${snmpagentinfo} Create Dictionary ip-address=${SNMP_IP} community=${SNMP_AGENT_COMM}
595 ${snmpagentcreate} Create Dictionary input=${snmpagentinfo}
596 ${snmpagentcreate_json}= json.dumps ${snmpagentcreate}
597 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_QUERY}
598 ${resp}= RequestsLibrary.Post Request session /restconf/operations/snmp:get-interfaces data=${snmpagentcreate_json}
599 ${convert}= To Json ${resp.content}
600 @{dict1}= Get Dictionary Keys ${convert}
601 ${dict1_0}= Get From List ${dict1} 0
602 ${dict1_val}= Get From Dictionary ${convert} ${dict1_0}
603 @{ifEntry}= Get From Dictionary ${dict1_val} ifEntry
604 @{SNMP_ENTRY}= Create List
605 @{SNMP_VALUES}= Create List
606 : FOR ${int} IN @{ifEntry}
607 \ ${ifindex}= Get From Dictionary ${int} ifIndex
608 \ ${ifOutDiscards}= Get From Dictionary ${int} ifOutDiscards
609 \ ${ifInDiscards}= Get From Dictionary ${int} ifInDiscards
610 \ ${ifType}= Get From Dictionary ${int} ifType
611 \ ${ifInOctets}= Get From Dictionary ${int} ifInOctets
612 \ ${ifSpeed}= Get From Dictionary ${int} ifSpeed
613 \ ${ifOutQLen}= Get From Dictionary ${int} ifOutQLen
614 \ ${ifOutErrors}= Get From Dictionary ${int} ifOutErrors
615 \ ${ifPhysAddress}= Get From Dictionary ${int} ifPhysAddress
616 \ ${ifInUcastPkts}= Get From Dictionary ${int} ifInUcastPkts
617 \ ${ifOutNUcastPkts}= Get From Dictionary ${int} ifOutNUcastPkts
618 \ ${ifInErrors}= Get From Dictionary ${int} ifInErrors
619 \ ${ifOutOctets}= Get From Dictionary ${int} ifOutOctets
620 \ ${ifAdminStatus1}= Get From Dictionary ${int} ifAdminStatus
621 \ ${ifAdminStatus}= Get From Dictionary ${OPER_STATUS} ${ifAdminStatus1}
622 \ ${ifInUnknownProtos}= Get From Dictionary ${int} ifInUnknownProtos
623 \ ${ifOutUcastPkts}= Get From Dictionary ${int} ifOutUcastPkts
624 \ ${ifInNUcastPkts}= Get From Dictionary ${int} ifInNUcastPkts
625 \ ${ifMtu}= Get From Dictionary ${int} ifMtu
626 \ ${ifOperStatus1}= Get From Dictionary ${int} ifOperStatus
627 \ ${ifOperStatus}= Get From Dictionary ${OPER_STATUS} ${ifOperStatus1}
628 \ Append To List ${SNMP_ENTRY} *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutDiscards*RK=ifIndex:${ifindex},SnmpMetric:IfOutDiscards*
629 \ Append To List ${SNMP_VALUES} ${ifOutDiscards}
630 \ Append To List ${SNMP_ENTRY} *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInDiscards*RK=ifIndex:${ifindex},SnmpMetric:IfInDiscards*
631 \ Append To List ${SNMP_VALUES} ${ifInDiscards}
632 \ Append To List ${SNMP_ENTRY} *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInOctets*RK=ifIndex:${ifindex},SnmpMetric:IfInOctets*
633 \ Append To List ${SNMP_VALUES} ${ifInOctets}
634 \ Append To List ${SNMP_ENTRY} *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutQLen*RK=ifIndex:${ifindex},SnmpMetric:IfOutQLen*
635 \ Append To List ${SNMP_VALUES} ${ifOutQLen}
636 \ Append To List ${SNMP_ENTRY} *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutErrors*RK=ifIndex:${ifindex},SnmpMetric:IfOutErrors*
637 \ Append To List ${SNMP_VALUES} ${ifOutErrors}
638 \ Append To List ${SNMP_ENTRY} *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInUcastPkts*RK=ifIndex:${ifindex},SnmpMetric:IfInUcastPkts*
639 \ Append To List ${SNMP_VALUES} ${ifInUcastPkts}
640 \ Append To List ${SNMP_ENTRY} *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutNUcastPkts*RK=ifIndex:${ifindex},SnmpMetric:IfOutNUcastPkts*
641 \ Append To List ${SNMP_VALUES} ${ifOutNUcastPkts}
642 \ Append To List ${SNMP_ENTRY} *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInErrors*RK=ifIndex:${ifindex},SnmpMetric:IfInErrors*
643 \ Append To List ${SNMP_VALUES} ${ifInErrors}
644 \ Append To List ${SNMP_ENTRY} *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutOctets*RK=ifIndex:${ifindex},SnmpMetric:IfOutOctets*
645 \ Append To List ${SNMP_VALUES} ${ifOutOctets}
646 \ Append To List ${SNMP_ENTRY} *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfAdminStatus*RK=ifIndex:${ifindex},SnmpMetric:IfAdminStatus*
647 \ Append To List ${SNMP_VALUES} ${ifAdminStatus}
648 \ Append To List ${SNMP_ENTRY} *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInUnknownProtos*RK=ifIndex:${ifindex},SnmpMetric:IfInUnknownProtos*
649 \ Append To List ${SNMP_VALUES} ${ifInUnknownProtos}
650 \ Append To List ${SNMP_ENTRY} *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutUcastPkts*RK=ifIndex:${ifindex},SnmpMetric:IfOutUcastPkts*
651 \ Append To List ${SNMP_VALUES} ${ifOutUcastPkts}
652 \ Append To List ${SNMP_ENTRY} *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInNUcastPkts*RK=ifIndex:${ifindex},SnmpMetric:IfInNUcastPkts*
653 \ Append To List ${SNMP_VALUES} ${ifInNUcastPkts}
654 \ Append To List ${SNMP_ENTRY} *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOperStatus*RK=ifIndex:${ifindex},SnmpMetric:IfOperStatus*
655 \ Append To List ${SNMP_VALUES} ${ifOperStatus}
656 [Return] ${SNMP_ENTRY} ${SNMP_VALUES}