*** Settings *** Library SSHLibrary Library RequestsLibrary Resource SSHKeywords.robot Resource ../variables/Variables.robot *** Variables *** ${mount_point_url} /restconf/operational/network-topology:network-topology/topology/topology-netconf/ ${device_status} /restconf/operational/odl-netconf-callhome-server:netconf-callhome-server ${whitelist} /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices ${substring1} "netconf-node-topology:connection-status":"connected" ${substring2} "node-id":"netopeer" ${substring3} "netconf-node-topology:available-capabilities" *** Keywords *** Check Device status [Arguments] ${status} ${id}=netopeer [Documentation] Checks the operational device status. @{expectedValues} Create List "unique-id":"${id}" "callhome-status:device-status":"${status}" Run Keyword If '${status}'=='FAILED_NOT_ALLOWED' or '${status}'=='FAILED_AUTH_FAILURE' Remove Values From List ${expectedValues} "unique-id":"${id}" Utils.Check For Elements At URI ${device_status} ${expectedValues} Get Netopeer Ready [Documentation] Pulls the netopeer image from the docker repository. Points ODL(CallHome Server) IP in the files used by netopeer(CallHome Client). ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command docker pull sdnhub/netopeer return_stdout=True return_stderr=True ... return_rc=True ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command docker images return_stdout=True return_stderr=True ... return_rc=True Reset Docker Compose Configuration Reset Docker Compose Configuration [Documentation] Resets the docker compose configurations. SSHLibrary.Put File ${CURDIR}/../variables/netconf/callhome/docker-compose.yaml . SSHLibrary.Put File ${CURDIR}/../variables/netconf/callhome/datastore-server.xml . SSHLibrary.Execute_Command sed -i -e 's/ODL_SYSTEM_IP/${ODL_SYSTEM_IP}/g' docker-compose.yaml SSHLibrary.Execute_Command sed -i -e 's/ODL_SYSTEM_IP/${ODL_SYSTEM_IP}/g' datastore-server.xml Get Environment Ready [Documentation] Get the scripts ready to set credentials and control whitelist maintained by the CallHome server. SSHLibrary.Put File ${CURDIR}/../variables/netconf/callhome/whitelist_add.sh . SSHLibrary.Put File ${CURDIR}/../variables/netconf/callhome/credentials_set.sh . SSHLibrary.Execute_Command chmod +x whitelist_add.sh SSHLibrary.Execute_Command chmod +x credentials_set.sh SSHLibrary.Execute_Command sed -i -e 's/ODL_SYSTEM_IP/${ODL_SYSTEM_IP}/g' credentials_set.sh SSHLibrary.Execute_Command sed -i -e 's/ODL_SYSTEM_IP/${ODL_SYSTEM_IP}/g' whitelist_add.sh Install Docker Compose on tools system [Documentation] Install docker-compose on tools system. ${netopeer_conn_id} = SSHKeywords.Open_Connection_To_Tools_System Builtin.Set Suite Variable ${netopeer_conn_id} SSHLibrary.Write sudo curl -L "https://github.com/docker/compose/releases/download/1.11.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose ${output}= Wait Until Keyword Succeeds 30s 2s SSHLibrary.Read_Until_Prompt ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command sudo chmod +x /usr/local/bin/docker-compose return_stdout=True return_stderr=True ... return_rc=True Uninstall Docker Compose on tools system [Documentation] Uninstall docker-compose on tools system ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command pip uninstall docker-compose return_stdout=True return_stderr=True ... return_rc=True Suite Teardown [Documentation] Tearing down the setup. Uninstall Docker Compose on tools system RequestsLibrary.Delete_All_Sessions SSHLibrary.Close_All_Connections Test Teardown [Documentation] Tears down the docker running netopeer and deletes entry from the whitelist. ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command docker-compose down return_stdout=True return_stderr=True ... return_rc=True ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command docker ps -a return_stdout=True return_stderr=True ... return_rc=True ${resp} = RequestsLibrary.Delete_Request session ${whitelist} Suite Setup [Documentation] Get the suite ready for callhome test cases. RequestsLibrary.Create_Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} Install Docker Compose on tools system Get Environment Ready Get Netopeer Ready ${netconf_mount_expected_values} Create list ${substring1} ${substring2} ${substring3} Set Suite Variable ${netconf_mount_expected_values}