[VOL-2472] - Implement the keyword to enable/disable web power-switch outlet

- Support the custom debug arguments for system-testing

Change-Id: Ief671dcbf8951edd954c6611be0fd441d2ffc570
diff --git a/Makefile b/Makefile
index 438f7f4..eb72d07 100644
--- a/Makefile
+++ b/Makefile
@@ -83,7 +83,7 @@
 bbsim-scale-kind: voltha-test
 
 system-scale-test: ROBOT_FILE := Voltha_PODTests.robot
-system-scale-test: ROBOT_MISC_ARGS += -X -i sanity
+system-scale-test: ROBOT_MISC_ARGS += -X -i sanity $(ROBOT_DEBUG_LOG_OPT)
 system-scale-test: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
 system-scale-test: k8s-system-test
 
diff --git a/libraries/power_switch.robot b/libraries/power_switch.robot
new file mode 100644
index 0000000..6d9c118
--- /dev/null
+++ b/libraries/power_switch.robot
@@ -0,0 +1,57 @@
+# 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 Digital Loggers Web Power Switch
+                  ...    Official Document: https://www.digital-loggers.com/rest.html
+Library           Collections
+Library           RequestsLibrary
+
+*** Variables ***
+${timeout}       60s
+${alias_name}    Switch Outlet
+${restapi_uri}   restapi/relay/outlets/
+
+*** Keywords ***
+Power Switch Connection Suite
+    [Arguments]    ${ip}    ${username}    ${password}
+    [Documentation]    Setup The HTTP Session To Web Power Switch
+    ${auth}=    Create List    ${username}    ${password}
+    ${headers}=    Create Dictionary
+    Set To Dictionary    ${headers}    X-CSRF    x
+    Set To Dictionary    ${headers}    Content-Type    application/x-www-form-urlencoded
+    Create Digest Session    alias=${alias_name}    url=http://${ip}/${restapi_uri}
+    ...    auth=${auth}    headers=${headers}
+
+Enable Switch Outlet
+    [Arguments]    ${outlet_number}
+    [Documentation]    Enable specific outlet of the Web Power Switch
+    ${resp}=    Put Request    alias=${alias_name}    uri==${outlet_number}/state/    data=value=true
+    Should Be Equal As Strings  ${resp.status_code}  207
+    Wait Until Keyword Succeeds    ${timeout}    2s
+    ...    Check Expected Switch Outlet Status    ${outlet_number}    true
+
+Disable Switch Outlet
+    [Arguments]    ${outlet_number}
+    [Documentation]    Disable specific outlet of the Web Power Switch
+    ${resp}=    Put Request    alias=${alias_name}    uri==${outlet_number}/state/    data=value=false
+    Should Be Equal As Strings  ${resp.status_code}  207
+    Wait Until Keyword Succeeds    ${timeout}    2s
+    ...    Check Expected Switch Outlet Status    ${outlet_number}    false
+
+Check Expected Switch Outlet Status
+    [Arguments]    ${outlet_number}    ${status}
+    [Documentation]    Succeeds if the status of the desired switch outlet is expected
+    ${resp}=    Get Request    alias=${alias_name}    uri==${outlet_number}/state/
+    Should Be Equal As Strings  ${resp.text}  [${status}]