Refactor Copy File To Remote System keyword 66/54066/10
authorJamo Luhrsen <jluhrsen@redhat.com>
Wed, 29 Mar 2017 18:59:00 +0000 (11:59 -0700)
committerVratko Polák <vrpolak@cisco.com>
Thu, 27 Apr 2017 08:31:50 +0000 (08:31 +0000)
- this is per comments here:
  https://git.opendaylight.org/gerrit/#/c/53812/6/csit/libraries/SSHKeywords.robot@194

Change-Id: I13794fe7e975d7a1e0ab16e90a90624f1464d636
Signed-off-by: Jamo Luhrsen <jluhrsen@redhat.com>
csit/libraries/SSHKeywords.robot
csit/suites/aaa/tls/010__aaa_restconf_tls.robot

index 870f90494101d259a5b0107b1135b13e3b9ff753..91718c2f50f844cee03b4b4e052b9b0cc42128e1 100644 (file)
@@ -17,6 +17,7 @@ Documentation     Resource enhancing SSHLibrary with Keywords used in multiple s
 ...               That may include Utils.Flexible_SSH_Login, and similar.
 Library           SSHLibrary
 Resource          ${CURDIR}/Utils.robot
+Resource          ../variables/Variables.robot
 
 *** Variables ***
 ${SSHKeywords__current_remote_working_directory}    .
@@ -191,11 +192,30 @@ Virtual_Env_Deactivate_On_Current_Session
     ${output}=    SSHLibrary.Read_Until_Prompt
     BuiltIn.Run_Keyword_If    ${log_output}==${True}    BuiltIn.Log    ${output}
 
-Copy File To Remote System
-    [Arguments]    ${system}    ${source}    ${destination}    ${user}=${TOOLS_SYSTEM_USER}    ${password}=${TOOLS_SYSTEM_PASSWORD}    ${prompt}=${TOOLS_SYSTEM_PROMPT}
+Unsafe_Copy_File_To_Remote_System
+    [Arguments]    ${system}    ${source}    ${destination}=./    ${user}=${DEFAULT_USER}    ${password}=${DEFAULT_PASSWORD}    ${prompt}=${DEFAULT_LINUX_PROMPT}
     ...    ${prompt_timeout}=5s
-    [Documentation]    Simplifies copy file operations to remote system
-    ${conn_id}=    Open Connection    ${system}    prompt=${prompt}    timeout=${prompt_timeout}
-    Flexible SSH Login    ${user}    ${password}
-    SSHLibrary.Put File    ${source}    ${destination}
-    Close Connection
+    [Documentation]    Copy the ${source} file to the ${destination} file on the remote ${system}. The keyword opens and closes a single
+    ...    ssh connection and does not rely on any existing ssh connection that may be open.
+    SSHLibrary.Open_Connection    ${system}    prompt=${prompt}    timeout=${prompt_timeout}
+    Utils.Flexible_SSH_Login    ${user}    ${password}
+    SSHLibrary.Put_File    ${source}    ${destination}
+    SSHLibrary.Close Connection
+
+Copy_File_To_Remote_System
+    [Arguments]    ${system}    ${source}    ${destination}=./    ${user}=${DEFAULT_USER}    ${password}=${DEFAULT_PASSWORD}    ${prompt}=${DEFAULT_LINUX_PROMPT}
+    ...    ${prompt_timeout}=5s
+    [Documentation]    Copy the ${source} file to the ${destination} file on the remote ${system}. Any pre-existing active
+    ...    ssh connection will be retained.
+    SSHKeywords.Run_Keyword_Preserve_Connection    SSHKeywords.Unsafe_Copy_File_To_Remote_System    ${system}    ${source}    ${destination}    ${user}    ${password}
+    ...    ${prompt}    ${prompt_timeout}
+
+Copy_File_To_Odl_System
+    [Arguments]    ${system}    ${source}    ${destination}=./
+    [Documentation]    Wrapper keyword to make it easier to copy a file to an ODL specific system
+    SSHKeywords.Copy_File_To_Remote_System    ${system}    ${source}    ${destination}    ${ODL_SYSTEM_USER}    ${ODL_SYSTEM_PASSWORD}    ${ODL_SYSTEM_PROMPT}
+
+Copy_File_To_Tools_System
+    [Arguments]    ${system}    ${source}    ${destination}=./
+    [Documentation]    Wrapper keyword to make it easier to copy a file to an Tools specific system
+    SSHKeywords.Copy_File_To_Remote_System    ${system}    ${source}    ${destination}    ${TOOLS_SYSTEM_USER}    ${TOOLS_SYSTEM_PASSWORD}    ${TOOLS_SYSTEM_PROMPT}
index e9d26c69dfc46bf6f21b284770de0f07a7293961..9caffd2eabb7e457acf0e554045b0ca9567d7807 100644 (file)
@@ -176,7 +176,7 @@ Generate Client Self-Signed Certificate
     # limitation in pycurl library that does not support key pem files with passphrase in automatic mode (it asks for it)
     Run    openssl req -x509 -newkey rsa:4096 -nodes -keyout ${USER_HOME}/clientkey.pem -out ${USER_HOME}/clientcert.pem -days 365 -subj "/C=ES/ST=Madrid/L=Madrid/O=OpenDayLight/OU=AAA/CN=MiguelAngelMunoz/emailAddress=myemail@unknown.com"
     # Import client's cert as trusted
-    Copy File To Remote System    ${ODL_SYSTEM_IP}    ${USER_HOME}/clientcert.pem    .
+    Copy File To Odl System    ${ODL_SYSTEM_IP}    ${USER_HOME}/clientcert.pem
     Run Command On Remote System    ${ODL_SYSTEM_IP}    ${JAVA_HOME}/bin/keytool -import -trustcacerts -file clientcert.pem -keystore ${KEYSTORE_PATH} -storepass 123456 -noprompt
     Log Certificates in Keystore
     Restart Jetty
@@ -194,7 +194,7 @@ Generate Server CA Signed Certificate
     Run    openssl x509 -req -in ${USER_HOME}/server.csr -CA ${USER_HOME}/rootCA.pem -CAkey ${USER_HOME}/rootCA.key -CAcreateserial -out ${USER_HOME}/server.crt -days 500 -sha256
     # Convert to pkcs12 (including public and private key together)
     Run    openssl pkcs12 -export -in ${USER_HOME}/server.crt -inkey ${USER_HOME}/server.key -out ${USER_HOME}/server.p12 -name odl -passin pass:myPass -passout pass:myPass
-    Copy File To Remote System    ${ODL_SYSTEM_IP}    ${USER_HOME}/server.p12    .
+    Copy File To Odl System    ${ODL_SYSTEM_IP}    ${USER_HOME}/server.p12
     # Import Certifcate into keystore
     ${KEYSTORE_DIR}=    Split Path    ${KEYSTORE_PATH}
     Run Command On Remote System    ${ODL_SYSTEM_IP}    mkdir -p ${KEYSTORE_DIR[0]}
@@ -213,7 +213,7 @@ Generate Client CA Signed Certificate
     Run    openssl req -new -key ${USER_HOME}/client_ca_signed-key.pem -out ${USER_HOME}/client_ca_signed.csr -subj "/C=ES/ST=Madrid/L=Madrid/O=OpenDayLight/OU=RestClient/CN=RestClient/emailAddress=unknown@unknownclient.com"
     #Sign CSR
     Run    openssl x509 -req -in ${USER_HOME}/client_ca_signed.csr -CA ${USER_HOME}/rootCA_for_clients-cert.pem -CAkey ${USER_HOME}/rootCA_for_clients-key.pem -CAcreateserial -out ${USER_HOME}/client_ca_signed-cert.pem -days 500 -sha256
-    Copy File To Remote System    ${ODL_SYSTEM_IP}    ${USER_HOME}/rootCA_for_clients-cert.pem    .
+    Copy File To Odl System    ${ODL_SYSTEM_IP}    ${USER_HOME}/rootCA_for_clients-cert.pem
     # Import RootCA Certifcate into keystore
     ${KEYSTORE_DIR}=    Split Path    ${KEYSTORE_PATH}
     Run Command On Remote System    ${ODL_SYSTEM_IP}    mkdir -p ${KEYSTORE_DIR[0]}