X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Flibraries%2FMininetKeywords.robot;h=b8faeed66b1c02d790a8dd3351af2ca20421dbfe;hb=ab2ca43d8088b84f51764ba79f2321786ecbe8c7;hp=2528d7882f3750dee9a157a35a96a286fe38c96f;hpb=d429e3c8acaccd2e34163a45e28d85ecba58df16;p=integration%2Ftest.git diff --git a/csit/libraries/MininetKeywords.robot b/csit/libraries/MininetKeywords.robot index 2528d7882f..b8faeed66b 100644 --- a/csit/libraries/MininetKeywords.robot +++ b/csit/libraries/MininetKeywords.robot @@ -1,27 +1,31 @@ *** Settings *** Documentation Mininet library. This library is useful for tests using mininet tool to simulate devices. Library SSHLibrary +Resource SSHKeywords.robot Resource Utils.robot Resource OVSDB.robot Resource ClusterManagement.robot Variables ../variables/Variables.py *** Variables *** +${switch_private_key} switch.key +${switch_certificate} switch.crt +${controller_ca_list} cachain.crt ${topology_file} create_fullymesh.py ${topology_file_path} MininetTopo/${topology_file} *** Keywords *** Start Mininet Single Controller - [Arguments] ${mininet}=${TOOLS_SYSTEM_IP} ${controller}=${ODL_SYSTEM_IP} ${options}=--topo tree,1 --switch ovsk,protocols=OpenFlow13 ${custom}=${EMPTY} ${ofport}=${ODL_OF_PORT} ${timeout}=${DEFAULT_TIMEOUT} + [Arguments] ${mininet}=${TOOLS_SYSTEM_IP} ${controller}=${ODL_SYSTEM_IP} ${options}=--topo tree,1 ${custom}=${EMPTY} ${ofversion}=13 ${ofport}=${ODL_OF_PORT} + ... ${timeout}=${DEFAULT_TIMEOUT} [Documentation] Start Mininet with custom topology and connect to controller. Log Clear any existing mininet Utils.Clean Mininet System ${mininet} - ${mininet_conn_id}= SSHLibrary.Open Connection ${mininet} prompt=${TOOLS_SYSTEM_PROMPT} timeout=${timeout} + ${mininet_conn_id}= SSHKeywords.Open_Connection_To_Tools_System ip_address=${mininet} timeout=${timeout} Set Suite Variable ${mininet_conn_id} - Utils.Flexible Mininet Login Run Keyword If '${custom}' != '${EMPTY}' Put File ${custom} Log Start mininet ${options} to ${controller} - SSHLibrary.Write sudo mn --controller 'remote,ip=${controller},port=${ofport}' ${options} + SSHLibrary.Write sudo mn --controller 'remote,ip=${controller},port=${ofport}' ${options} --switch ovsk,protocols=OpenFlow${ofversion} SSHLibrary.Read Until mininet> Log Check OVS configuratiom SSHLibrary.Write sh ovs-vsctl show @@ -29,59 +33,67 @@ Start Mininet Single Controller [Return] ${mininet_conn_id} Start Mininet Multiple Controllers - [Arguments] ${mininet} ${controller_index_list}=${EMPTY} ${options}=--topo tree,1 --switch ovsk,protocols=OpenFlow13 ${custom}=${EMPTY} ${ofport}=${ODL_OF_PORT} ${timeout}=${DEFAULT_TIMEOUT} + [Arguments] ${mininet}=${TOOLS_SYSTEM_IP} ${controller_index_list}=${EMPTY} ${options}=--topo tree,1 ${custom}=${EMPTY} ${ofversion}=13 ${ofport}=${ODL_OF_PORT} + ... ${protocol}=tcp ${timeout}=${DEFAULT_TIMEOUT} [Documentation] Start Mininet with custom topology and connect to list of controllers in ${controller_index_list} or all if no list is provided. ${index_list} = ClusterManagement.List Indices Or All given_list=${controller_index_list} Log Clear any existing mininet Utils.Clean Mininet System ${mininet} - ${mininet_conn_id}= SSHLibrary.Open Connection ${mininet} prompt=${TOOLS_SYSTEM_PROMPT} timeout=${timeout} + ${mininet_conn_id}= SSHKeywords.Open_Connection_To_Tools_System ip_address=${mininet} timeout=${timeout} Set Suite Variable ${mininet_conn_id} - Utils.Flexible Mininet Login Run Keyword If '${custom}' != '${EMPTY}' Put File ${custom} + Run Keyword If '${protocol}' == 'ssl' Install Certificates In Mininet Log Start mininet ${options} SSHLibrary.Write sudo mn ${options} SSHLibrary.Read Until mininet> Log Create controller configuration ${controller_opt}= Set Variable : FOR ${index} IN @{index_list} - \ ${controller_opt}= Catenate ${controller_opt} ${SPACE}tcp:${ODL_SYSTEM_${index}_IP}:${ofport} + \ ${controller_opt}= Catenate ${controller_opt} ${SPACE}${protocol}:${ODL_SYSTEM_${index}_IP}:${ofport} \ Log ${controller_opt} - Log Find Number of OVS bridges - ${num_bridges} Utils.Run Command On Mininet ${mininet} sudo ovs-vsctl show | grep Bridge | wc -l + Log Open extra SSH connection to configure the OVS bridges + SSHKeywords.Open_Connection_To_Tools_System ip_address=${mininet} timeout=${timeout} + ${num_bridges} SSHLibrary.Execute Command sudo ovs-vsctl show | grep Bridge | wc -l ${num_bridges}= Convert To Integer ${num_bridges} - Log Configure OVS controllers ${controller_opt} in all bridges + ${bridges}= Create List : FOR ${i} IN RANGE 1 ${num_bridges+1} - \ ${bridge}= Utils.Run Command On Mininet ${mininet} sudo ovs-vsctl show | grep Bridge | cut -c 12- | sort | head -${i} | tail -1 - \ OVSDB.Set Controller In OVS Bridge ${mininet} ${bridge} ${controller_opt} + \ ${bridge}= SSHLibrary.Execute Command sudo ovs-vsctl show | grep Bridge | cut -c 12- | sort | head -${i} | tail -1 + \ SSHLibrary.Execute Command sudo ovs-vsctl del-controller ${bridge} && sudo ovs-vsctl set bridge ${bridge} protocols=OpenFlow${ofversion} + \ Collections.Append To List ${bridges} ${bridge} + Log Configure OVS controllers ${controller_opt} in all bridges + : FOR ${bridge} IN @{bridges} + \ SSHLibrary.Execute Command sudo ovs-vsctl set-controller ${bridge} ${controller_opt} Log Check OVS configuratiom - SSHLibrary.Write sh ovs-vsctl show - SSHLibrary.Read Until mininet> + ${output}= SSHLibrary.Execute Command sudo ovs-vsctl show + Log ${output} + SSHLibrary.Close Connection [Return] ${mininet_conn_id} Start Mininet Multiple Hosts - [Arguments] ${hosts} ${mininet}=${TOOLS_SYSTEM_IP} ${controller}=${ODL_SYSTEM_IP} ${mininet_timeout}=${DEFAULT_TIMEOUT} + [Arguments] ${hosts} ${mininet}=${TOOLS_SYSTEM_IP} ${controller}=${ODL_SYSTEM_IP} ${ofversion}=13 ${ofport}=${ODL_OF_PORT} ${mininet_timeout}=${DEFAULT_TIMEOUT} [Documentation] Start mininet 1 switch with ${hosts} hosts attached. Log Start Mininet Linear - MininetKeywords.StartMininet Single Controller options=--topo single,${hosts} --mac --switch ovsk,protocols=OpenFlow13 timeout=${mininet_timeout} + MininetKeywords.StartMininet Single Controller options=--topo single,${hosts} --mac ofversion=${ofversion} ofport=${ofport} timeout=${mininet_timeout} Start Mininet Linear - [Arguments] ${switches} ${mininet}=${TOOLS_SYSTEM_IP} ${controller}=${ODL_SYSTEM_IP} ${mininet_timeout}=${DEFAULT_TIMEOUT} + [Arguments] ${switches} ${mininet}=${TOOLS_SYSTEM_IP} ${controller}=${ODL_SYSTEM_IP} ${ofversion}=13 ${ofport}=${ODL_OF_PORT} ${mininet_timeout}=${DEFAULT_TIMEOUT} [Documentation] Start mininet linear topology with ${switches} nodes. Log Start Mininet Linear - MininetKeywords.StartMininet Single Controller options=--topo linear,${switches} --switch ovsk,protocols=OpenFlow13 timeout=${mininet_timeout} + MininetKeywords.StartMininet Single Controller options=--topo linear,${switches} ofversion=${ofversion} ofport=${ofport} timeout=${mininet_timeout} Start Mininet Full Mesh - [Arguments] ${switches} ${mininet}=${TOOLS_SYSTEM_IP} ${controller}=${ODL_SYSTEM_IP} ${hosts}=0 ${mininet_timeout}=${DEFAULT_TIMEOUT} + [Arguments] ${switches} ${mininet}=${TOOLS_SYSTEM_IP} ${controller}=${ODL_SYSTEM_IP} ${ofversion}=13 ${ofport}=${ODL_OF_PORT} ${hosts}=0 + ... ${mininet_timeout}=${DEFAULT_TIMEOUT} [Documentation] Start a custom mininet topology. ${mininet_conn_id}= SSHLibrary.Open Connection ${mininet} prompt=${TOOLS_SYSTEM_PROMPT} timeout=${mininet_timeout} Set Suite Variable ${mininet_conn_id} - Utils.Flexible_Mininet_Login + SSHKeywords.Flexible_Mininet_Login Log Copying ${topology_file_path} file to Mininet VM and Creating Full Mesh topology SSHLibrary.Put File ${CURDIR}/${topology_file_path} SSHLibrary.Write python ${topology_file} ${switches} ${hosts} 00:00:00:00:00:00 10.0.0.0 SSHLibrary.Read Until ${TOOLS_SYSTEM_PROMPT} Log Start Mininet Full Mesh - SSHLibrary.Write sudo mn --controller=remote,ip=${controller} --custom switch.py --topo demotopo --switch ovsk,protocols=OpenFlow13 + SSHLibrary.Write sudo mn --controller=remote,ip=${controller},port=${ofport} --custom switch.py --topo demotopo --switch ovsk,protocols=OpenFlow${ofversion} SSHLibrary.Read Until mininet> Log Check OVS configuratiom SSHLibrary.Write sh ovs-vsctl show @@ -103,7 +115,7 @@ Send Mininet Command Multiple Sessions ${output_list}= Create List : FOR ${mininet_conn} IN @{mininet_conn_list} \ ${output}= Utils.Send Mininet Command ${mininet_conn} ${cmd} - \ Append To List ${output_list} ${output} + \ Collections.Append To List ${output_list} ${output} [Return] ${output_list} Stop Mininet And Exit @@ -190,5 +202,17 @@ Get Mininet Hosts @{words}= String.Split String ${out} ${SPACE} : FOR ${item} IN @{words} \ ${h}= String.Get Lines Matching Regexp ${item} h[0-9]* - \ Run Keyword If '${h}' != '${EMPTY}' Append To List ${host_list} ${h} + \ Run Keyword If '${h}' != '${EMPTY}' Collections.Append To List ${host_list} ${h} [Return] ${host_list} + +Install Certificates In Mininet + [Documentation] Copy and install certificates in simulator. + Comment Copy Certificates + SSHLibrary.Put File ${CURDIR}/tls/${switch_private_key} . + SSHLibrary.Put File ${CURDIR}/tls/${switch_certificate} . + SSHLibrary.Put File ${CURDIR}/tls/${controller_ca_list} . + Comment Install Certificates + SSHLibrary.Execute Command sudo mv ${switch_private_key} /etc/openvswitch && sudo mv ${switch_certificate} /etc/openvswitch && sudo mv ${controller_ca_list} /etc/openvswitch + SSHLibrary.Execute Command sudo ovs-vsctl set-ssl /etc/openvswitch/${switch_private_key} /etc/openvswitch/${switch_certificate} /etc/openvswitch/${controller_ca_list} + ${std_out}= SSHLibrary.Execute Command . sudo ovs-vsctl get-ssl + Log ${std_out}