VOL-2642 Add a Makefile, tests, and virtualenv
Convert common python and robot into a CORDRobot python module that can
be installed via standard python tools (pip) and from PyPI
Uses a fork of https://github.com/rasjani/robotframework-importresource,
which has been backported to Python 3.5 (used in Ubuntu 16.04
executors).
Reformatted and moved keywords so resource files are scoped to a
specific topic.
Added tox tests for library consistency
- flake8
- pylint
- robotframework-lint
- Ran robot against installed library to verify it can be loaded and
used
Added basic lint and tests to whole repo
Removed old tests:
- CORD <6.x era: SanityPhyPOD.robot, and onosUtils.py
Change-Id: I61265a9fb04034a086e20be1f7236a8793a218aa
diff --git a/cord-robot/CORDRobot/rf-resources/CIAB.resource b/cord-robot/CORDRobot/rf-resources/CIAB.resource
new file mode 100644
index 0000000..e765d2d
--- /dev/null
+++ b/cord-robot/CORDRobot/rf-resources/CIAB.resource
@@ -0,0 +1,76 @@
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+*** Settings ***
+Documentation Library for CORD-in-a-Box
+Library SSHLibrary
+Resource utils.resource
+
+*** Keywords ***
+Execute Command on CIAB Server in Specific VM
+ [Documentation] SSHs into ${HOST} where CIAB is running and executes a
+ ... command in the Prod Vagrant VM where all the containers are running
+ [Arguments] ${system} ${vm} ${cmd}
+ ... ${user}=${VM_USER} ${password}=${VM_PASS}
+ ... ${prompt}=$ ${use_key}=True ${strip_line}=True
+ ${conn_id}= SSHLibrary.Open Connection ${system} prompt=${prompt} timeout=300s
+ Run Keyword If '${use_key}' == 'False'
+ ... SSHLibrary.Login ${user} ${pass}
+ ... ELSE
+ ... SSHLibrary.Login With Public Key ${user} %{HOME}/.ssh/${SSH_KEY} any
+ SSHLibrary.Write ssh ${vm}
+ SSHLibrary.Read Until Prompt
+ SSHLibrary.Write ${cmd}
+ ${output}= SSHLibrary.Read Until Prompt
+ SSHLibrary.Close Connection
+ ${output_1}= Run Keyword If '${strip_line}' == 'True' Get Line ${output} 0
+ ${output}= Set Variable If '${strip_line}' == 'True' ${output_1} ${output}
+ [Return] ${output}
+
+Execute Command on Compute Node in CIAB
+ [Documentation] SSHs into ${system} where CIAB is running and executes a
+ ... command in the Prod Vagrant VM where all the containers are running
+ [Arguments] ${system} ${node} ${hostname} ${cmd}
+ ... ${user}=${VM_USER} ${password}=${VM_PASS} ${prompt}=$ ${use_key}=True
+ ${conn_id}= SSHLibrary.Open Connection ${system} prompt=${prompt} timeout=300s
+ # FIXME: Truthy comparison of strings
+ Run Keyword If '${use_key}' == 'False'
+ ... SSHLibrary.Login ${user} ${pass}
+ ... ELSE
+ ... SSHLibrary.Login With Public Key ${user} %{HOME}/.ssh/${SSH_KEY} any
+ SSHLibrary.Write ssh ${node}
+ SSHLibrary.Read Until Prompt
+ SSHLibrary.Write ssh root@${hostname}
+ SSHLibrary.Read Until \#
+ SSHLibrary.Write ${cmd}
+ ${output}= SSHLibrary.Read Until \#
+ SSHLibrary.Close Connection
+ [Return] ${output}
+
+Get Docker Logs
+ ##In Ciab, all containers are run in the prod vm so we must log into that
+ [Documentation] Retrieves the logs of a docker container running inside
+ ... given ${system}
+ [Arguments] ${system} ${container_id}
+ ... ${user}=${USER} ${password}=${PASSWD} ${prompt}=prod:~$
+ ${conn_id}= SSHLibrary.Open Connection ${system} prompt=$ timeout=300s
+ SSHLibrary.Login With Public Key ${USER} %{HOME}/.ssh/${SSH_KEY} any
+ #SSHLibrary.Login ${HOST_USER} ${HOST_PASSWORD}
+ SSHLibrary.Write ssh head1
+ SSHLibrary.Read Until ${prompt}
+ SSHLibrary.Write docker logs -t ${container_id}
+ ${container_logs}= SSHLibrary.Read Until ${prompt}
+ SSHLibrary.Close Connection
+ Log ${container_logs}
+ [Return] ${container_logs}