diff --git a/.github/workflows/uc_sanity.yml b/.github/workflows/uc_sanity.yml index f7ddab021..9d79e8495 100644 --- a/.github/workflows/uc_sanity.yml +++ b/.github/workflows/uc_sanity.yml @@ -63,6 +63,83 @@ jobs: - name: push docker image run: docker push ${{ env.DOCKER_SERVER }}/cloud-sdk-nightly:${{ github.run_id }} + deploy-controller: + name: deploy uCentral controller + runs-on: ubuntu-latest + outputs: + gateway_url: ${{ steps.gateway_url.outputs.value }} + sec_url: ${{ steps.sec_url.outputs.value }} + namespace: ${{ steps.namespace.outputs.value }} + steps: + - name: Checkout repo with Helm values + uses: actions/checkout@v2 + with: + path: wlan-testing + + - name: Prepare certificates from secrets + working-directory: wlan-testing/helm/ucentral + run: | + echo "${{ secrets.DIGICERT_CERT }}" | base64 -d > cert.pem + echo "${{ secrets.DIGICERT_KEY }}" | base64 -d > key.pem + + - name: Fetch kubeconfig + run: | + aws eks update-kubeconfig --name ${{ env.AWS_EKS_NAME }} + + - name: Set namespace output + id: namespace + run: echo "::set-output name=value::ucentral-${{ github.run_id }}" + + - name: Set gateway URL output + id: gateway_url + run: echo "::set-output name=value::gw-ucentral-${{ github.run_id }}.cicd.lab.wlan.tip.build" + + - name: Set sec service URL output + id: sec_url + run: echo "::set-output name=value::sec-ucentral-${{ github.run_id }}.cicd.lab.wlan.tip.build" + + - name: Deploy uCentralGW + working-directory: wlan-testing/helm/ucentral + run: | + export NAMESPACE=${{ github.run_id }} + export DEPLOY_METHOD=git + export CHART_VERSION=main + export UCENTRALGW_VERSION=master + export UCENTRALGWUI_VERSION=main + export UCENTRALSEC_VERSION=main + export UCENTRALFMS_VERSION=main + export VALUES_FILE_LOCATION=values.ucentral-qa.yaml + export RTTY_TOKEN=${{ secrets.RTTY_TOKEN }} + export UCENTRALGW_AUTH_USERNAME=${{ secrets.UCENTRALGW_AUTH_USERNAME }} + export UCENTRALGW_AUTH_PASSWORD=${{ secrets.UCENTRALGW_AUTH_PASSWORD }} + export UCENTRALFMS_S3_SECRET=${{ secrets.UCENTRALFMS_S3_SECRET }} + export UCENTRALFMS_S3_KEY=${{ secrets.UCENTRALFMS_S3_KEY }} + export CERT_LOCATION=cert.pem + export KEY_LOCATION=key.pem + ./deploy.sh + + - name: Show resource state on deployment failure + if: failure() + run: | + kubectl get pods --namespace ucentral-${{ matrix.namespace }} + kubectl get services --namespace ucentral-${{ matrix.namespace }} + kubectl get persistentvolumeclaims --namespace ucentral-${{ matrix.namespace }} + - name: Describe pods on deployment failure + if: failure() + run: | + kubectl describe pods --namespace ucentral-${{ matrix.namespace }} + - name: Describe services on deployment failure + if: failure() + run: | + kubectl describe services --namespace ucentral-${{ matrix.namespace }} + - name: Describe persistentvolumeclaims on deployment failure + if: failure() + run: | + kubectl describe persistentvolumeclaims --namespace ucentral-${{ matrix.namespace }} + + - name: wait for DNS to propagate + run: sleep 300 + generate-matrix: name: generate testbed matrix runs-on: ubuntu-latest @@ -76,9 +153,71 @@ jobs: TESTBEDS=$(echo $TESTBEDS | sed "s/,/\",\"/g" | sed 's/^/[\"/g' | sed 's/$/\"]/g') TESTBEDS=$(echo "$TESTBEDS" | jq -c 'map({"testbed":.})') echo "::set-output name=matrix::{\"include\":${TESTBEDS}}" + + set-redirector-url: + needs: [ deploy-controller, generate-matrix ] + strategy: + fail-fast: false + matrix: ${{ fromJson( needs.generate-matrix.outputs.matrix ) }} + runs-on: self-hosted + steps: + - name: checkout testing repo + uses: actions/checkout@v2 + with: + repository: Telecominfraproject/wlan-testing + path: wlan-testing + ref: WIFI-3620 + + - name: checkout pki cert scripts repo + uses: actions/checkout@v2 + with: + repository: Telecominfraproject/wlan-pki-cert-scripts + path: wlan-pki-cert-scripts + + - name: install dependencies + run: | + sudo apt-get install -y python3-pip + pip install paramiko scp allure-pytest + + - name: create configuration.py file + run: | + cat << EOF > configuration.py + ${{ secrets.LAB_CONFIGURATION }} + EOF + + - name: set redirector URL + env: + DIGICERT_API_KEY: ${{ secrets.DIGICERT_API_KEY }} + run: | + for id in $(echo -e 'from configuration import CONFIGURATION\nfor ap in CONFIGURATION["${{ matrix.testbed }}"]["access_point"]: print(ap["serial"])' | python3) + do + ./wlan-pki-cert-scripts/digicert-change-ap-redirector.sh $id "${{ needs.deploy-controller.outputs.gateway_url }}" + done + + - name: factory reset APs + run: | + set -x + AP_LEN=$(echo -e "from configuration import CONFIGURATION\nprint(len(CONFIGURATION['${{ matrix.testbed }}']['access_point']) - 1)" | python3) + for index in $(seq 0 $AP_LEN) + do + HOST=$(echo -e "from configuration import CONFIGURATION\nprint(CONFIGURATION['${{ matrix.testbed }}']['access_point'][$index]['ip'])" | python3) + JUMPHOST=$(echo -e "from configuration import CONFIGURATION\nprint(CONFIGURATION['${{ matrix.testbed }}']['access_point'][$index]['jumphost'])" | python3) + TTY=$(echo -e "from configuration import CONFIGURATION\nprint(CONFIGURATION['${{ matrix.testbed }}']['access_point'][$index]['jumphost_tty'])" | python3) + PORT=$(echo -e "from configuration import CONFIGURATION\nprint(CONFIGURATION['${{ matrix.testbed }}']['access_point'][$index]['port'])" | python3) + USERNAME=$(echo -e "from configuration import CONFIGURATION\nprint(CONFIGURATION['${{ matrix.testbed }}']['access_point'][$index]['username'])" | python3) + PASSWORD=$(echo -e "from configuration import CONFIGURATION\nprint(CONFIGURATION['${{ matrix.testbed }}']['access_point'][$index]['password'])" | python3) + + cd wlan-testing/tools + python3 ap_tools.py --host $HOST --jumphost $JUMPHOST --tty $TTY --port $PORT --username $USERNAME --password $PASSWORD --cmd "jffs2reset -y -r" + cd ../.. + done + + - name: wait for APs to come up again + run: sleep 60 + test: runs-on: ubuntu-latest - needs: [ build, generate-matrix ] + needs: [ build, generate-matrix, deploy-controller, set-redirector-url ] strategy: fail-fast: false matrix: ${{ fromJson( needs.generate-matrix.outputs.matrix ) }} @@ -106,6 +245,8 @@ jobs: cat << EOF > configuration.py ${{ secrets.LAB_CONFIGURATION }} EOF + sed -i -r "s/'url': ('|\").*('|\")/'url': 'https:\/\/${{ needs.deploy-controller.outputs.sec_url }}:16001'/" configuration.py + cat configuration.py kubectl create secret generic configuration --from-file=configuration=./configuration.py - name: run sanity tests run: | @@ -178,6 +319,7 @@ jobs: if: always() run: | kubectl delete ns "${{ steps.namespace.outputs.name }}" --wait=true + report: runs-on: ubuntu-latest needs: [ test, generate-matrix ] @@ -191,6 +333,7 @@ jobs: run: | wget https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/${{ env.ALLURE_CLI_VERSION }}/allure-commandline-${{ env.ALLURE_CLI_VERSION }}.tgz tar -xzf allure-commandline-${{ env.ALLURE_CLI_VERSION }}.tgz + - uses: actions/download-artifact@v2 with: name: allure-results-${{ matrix.testbed }} @@ -213,6 +356,7 @@ jobs: if [ -e "reports/sanity/${{ matrix.testbed }}/latest" ] ; then cp -r reports/sanity/${{ matrix.testbed }}/latest/history/ allure-results/history fi + - name: add report metadata run: | cat << EOF >> allure-results/environment.properties @@ -222,6 +366,7 @@ jobs: CiRun.Number=${{ github.run_number }} CiRun.Url=https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} EOF + - name: generate Allure report run: allure-${{ env.ALLURE_CLI_VERSION }}/bin/allure generate @@ -240,6 +385,7 @@ jobs: run: | mkdir -p reports/sanity/${{ matrix.testbed }} cp -Tr allure-report reports/sanity/${{ matrix.testbed }}/${{ github.run_number }} + - name: update latest symlink if: ${{ (github.event.inputs.marker_expression || 'uc_sanity') == 'uc_sanity' }} working-directory: reports/sanity/${{ matrix.testbed }} @@ -255,6 +401,7 @@ jobs: git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" git add . git commit -m "Automated deployment: $(date -u)" + - name: push if: github.ref == 'refs/heads/master' uses: ad-m/github-push-action@v0.6.0 @@ -263,10 +410,84 @@ jobs: branch: gh-pages directory: reports - cleanup: + delete-docker-image: needs: [ test ] runs-on: ubuntu-latest if: always() steps: - name: cleanup Docker image run: curl -u${{ env.DOCKER_USER_NAME }}:${{ env.DOCKER_USER_PASSWORD }} -X DELETE "https://tip.jfrog.io/artifactory/tip-wlan-cloud-docker-repo/cloud-sdk-nightly/${{ github.run_id }}" + + destroy-controller: + needs: [ test ] + runs-on: ubuntu-latest + if: always() + steps: + - name: Checkout repo with Helm values + uses: actions/checkout@v2 + with: + path: wlan-testing + + - name: Fetch kubeconfig + run: | + aws eks update-kubeconfig --name ${{ env.AWS_EKS_NAME }} + + - name: Delete namespace + run: kubectl delete ns --ignore-not-found=true "ucentral-${{ github.run_id }}" + + reset-redirector-url: + needs: [ test, generate-matrix ] + if: always() + strategy: + fail-fast: false + matrix: ${{ fromJson( needs.generate-matrix.outputs.matrix ) }} + runs-on: self-hosted + steps: + - name: checkout testing repo + uses: actions/checkout@v2 + with: + repository: Telecominfraproject/wlan-testing + path: wlan-testing + ref: WIFI-3620 + + - name: checkout pki cert scripts repo + uses: actions/checkout@v2 + with: + repository: Telecominfraproject/wlan-pki-cert-scripts + path: wlan-pki-cert-scripts + + - name: install dependencies + run: | + pip install paramiko scp allure-pytest + + - name: create configuration.py file + run: | + cat << EOF > configuration.py + ${{ secrets.LAB_CONFIGURATION }} + EOF + + - name: reset redirector URL + env: + DIGICERT_API_KEY: ${{ secrets.DIGICERT_API_KEY }} + run: | + for id in $(echo -e 'from configuration import CONFIGURATION\nfor ap in CONFIGURATION["${{ matrix.testbed }}"]["access_point"]: print(ap["serial"])' | python3) + do + ./wlan-pki-cert-scripts/digicert-change-ap-redirector.sh $id gw-ucentral-qa01.cicd.lab.wlan.tip.build + done + + - name: factory reset APs + run: | + AP_LEN=$(echo -e "from configuration import CONFIGURATION\nprint(len(CONFIGURATION['${{ matrix.testbed }}']['access_point']) - 1)" | python3) + for index in $(seq 0 $AP_LEN) + do + HOST=$(echo -e "from configuration import CONFIGURATION\nprint(CONFIGURATION['${{ matrix.testbed }}']['access_point'][$index]['ip'])" | python3) + JUMPHOST=$(echo -e "from configuration import CONFIGURATION\nprint(CONFIGURATION['${{ matrix.testbed }}']['access_point'][$index]['jumphost'])" | python3) + TTY=$(echo -e "from configuration import CONFIGURATION\nprint(CONFIGURATION['${{ matrix.testbed }}']['access_point'][$index]['jumphost_tty'])" | python3) + PORT=$(echo -e "from configuration import CONFIGURATION\nprint(CONFIGURATION['${{ matrix.testbed }}']['access_point'][$index]['port'])" | python3) + USERNAME=$(echo -e "from configuration import CONFIGURATION\nprint(CONFIGURATION['${{ matrix.testbed }}']['access_point'][$index]['username'])" | python3) + PASSWORD=$(echo -e "from configuration import CONFIGURATION\nprint(CONFIGURATION['${{ matrix.testbed }}']['access_point'][$index]['password'])" | python3) + + cd wlan-testing/tools + python3 ap_tools.py --host $HOST --jumphost $JUMPHOST --tty $TTY --port $PORT --username $USERNAME --password $PASSWORD --cmd "jffs2reset -y -r" + cd ../.. + done diff --git a/libs/apnos/apnos.py b/libs/apnos/apnos.py index 487d9e0e2..78de237ca 100644 --- a/libs/apnos/apnos.py +++ b/libs/apnos/apnos.py @@ -17,7 +17,6 @@ import random import paramiko from scp import SCPClient import os -import allure class APNOS: diff --git a/libs/controller/controller_2x/controller.py b/libs/controller/controller_2x/controller.py index b314b34f4..de6e97b93 100644 --- a/libs/controller/controller_2x/controller.py +++ b/libs/controller/controller_2x/controller.py @@ -34,13 +34,26 @@ class ConfigureController: self.access_token = "" # self.session = requests.Session() self.login_resp = self.login() - self.gw_host = self.get_gw_endpoint() + self.gw_host, self.fms_host = self.get_gw_endpoint() + if self.gw_host == "" or self.fms_host == "": + time.sleep(60) + self.gw_host, self.fms_host = self.get_gw_endpoint() + if self.gw_host == "" or self.fms_host == "": + self.logout() + print(self.gw_host, self.fms_host) + pytest.exit("All Endpoints not available in Controller Service") + sys.exit() def build_uri_sec(self, path): new_uri = 'https://%s:%d/api/v1/%s' % (self.host.hostname, self.host.port, path) print(new_uri) return new_uri + def build_url_fms(self, path): + new_uri = 'https://%s:%d/api/v1/%s' % (self.fms_host.hostname, self.fms_host.port, path) + print(new_uri) + return new_uri + def build_uri(self, path): new_uri = 'https://%s:%d/api/v1/%s' % (self.gw_host.hostname, self.gw_host.port, path) @@ -92,9 +105,15 @@ class ConfigureController: print(resp) self.check_response("GET", resp, self.make_headers(), "", uri) services = resp.json() - print(services["endpoints"][0]["uri"]) - gw_host = urlparse(services["endpoints"][0]["uri"]) - return gw_host + print(services) + gw_host = "" + fms_host = "" + for service in services['endpoints']: + if service['type'] == "ucentralgw": + gw_host = urlparse(service["uri"]) + if service['type'] == "ucentralfms": + fms_host = urlparse(service["uri"]) + return gw_host, fms_host def logout(self): uri = self.build_uri_sec('oauth2/%s' % self.access_token) @@ -155,6 +174,73 @@ class Controller(ConfigureController): return device_info["UUID"] +class FMSUtils: + + def __init__(self, sdk_client=None, controller_data=None): + if sdk_client is None: + self.sdk_client = Controller(controller_data=controller_data) + self.sdk_client = sdk_client + + def upgrade_firmware(self, serial="", url=""): + response = self.sdk_client.request(service="gw", command="device/" + serial + "upgrade/", + method="POST", params="revisionSet=true", + payload="{ \"serialNumber\" : " + serial + " , \"uri\" : " + url + " }") + print(response) + pass + + def ap_model_lookup(self, model=""): + devices = self.get_device_set() + model_name = "" + for device in devices['deviceTypes']: + if str(device).__contains__(model): + model_name = device + return model_name + + def get_revisions(self): + response = self.sdk_client.request(service="fms", command="firmwares/", method="GET", params="revisionSet=true", + payload="") + if response.status_code == 200: + return response.json() + else: + return {} + + def get_latest_fw(self, model=""): + + device_type = self.ap_model_lookup(model=model) + + response = self.sdk_client.request(service="fms", command="firmwares/", method="GET", + params="latestOnly=true&deviceType=" + device_type, + payload="") + if response.status_code == 200: + return response.json() + else: + return {} + + def get_device_set(self): + response = self.sdk_client.request(service="fms", command="firmwares/", method="GET", params="deviceSet=true", + payload="") + if response.status_code == 200: + return response.json() + else: + return {} + + def get_firmwares(self, limit="", deviceType="", latestonly=""): + + params = "limit=" + limit + "&deviceType=" + deviceType + "&latestonly=" + latestonly + + response = self.sdk_client.request(service="fms", command="firmwares/", method="GET", params=params, payload="") + print(response) + if response.status_code == 200: + data = response.json() + print(data) + + # resp = requests.get(uri, headers=self.sdk_client.make_headers(), verify=False, timeout=100) + # self.sdk_client.check_response("GET", resp, self.sdk_client.make_headers(), "", uri) + # devices = resp.json() + # # resp.close()() + return "devices" + + class UProfileUtility: def __init__(self, sdk_client=None, controller_data=None): @@ -344,7 +430,7 @@ class UProfileUtility: for options in ssid_data: if options == "multi-psk": ssid_info[options] = ssid_data[options] - print("hi",ssid_info) + print("hi", ssid_info) if options == "rate-limit": ssid_info[options] = ssid_data[options] for i in ssid_data["appliedRadios"]: @@ -435,13 +521,17 @@ if __name__ == '__main__': 'password': 'openwifi', } obj = Controller(controller_data=controller) - profile = UProfileUtility(sdk_client=obj) - profile.set_mode(mode="BRIDGE") - profile.set_radio_config() - ssid = {"ssid_name": "ssid_wpa2_2g", "appliedRadios": ["2G", "5G"], "security": "psk", "security_key": "something", - "vlan": 100} - profile.add_ssid(ssid_data=ssid, radius=False) - profile.push_config(serial_number="903cb39d6918") - print(profile.get_ssid_info()) - # print(obj.get_devices()) + fms = FMSUtils(sdk_client=obj) + # fms.get_device_set() + # model = fms.get_latest_fw(model="eap102") + # print(model) + # profile = UProfileUtility(sdk_client=obj) + # profile.set_mode(mode="BRIDGE") + # profile.set_radio_config() + # ssid = {"ssid_name": "ssid_wpa2_2g", "appliedRadios": ["2G", "5G"], "security": "psk", "security_key": "something", + # "vlan": 100} + # profile.add_ssid(ssid_data=ssid, radius=False) + # profile.push_config(serial_number="903cb39d6918") + # print(profile.get_ssid_info()) + # # print(obj.get_devices()) obj.logout() diff --git a/tests/e2e/basic/performance_tests/throughput_benchmark/throughput_vs_various_pkt_sizes/wpa_security/test_bridge_mode.py b/tests/e2e/basic/performance_tests/throughput_benchmark/throughput_vs_various_pkt_sizes/wpa_security/test_bridge_mode.py index ed14b3b27..bbc994e16 100644 --- a/tests/e2e/basic/performance_tests/throughput_benchmark/throughput_vs_various_pkt_sizes/wpa_security/test_bridge_mode.py +++ b/tests/e2e/basic/performance_tests/throughput_benchmark/throughput_vs_various_pkt_sizes/wpa_security/test_bridge_mode.py @@ -34,7 +34,7 @@ class TestThroughputVsPktBridgeWpa2G(object): """Throughput vs Various Pkt Size Test BRIDGE MODE pytest -m "throughput_vs_pkt and Bridge" """ - + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pkt60 @@ -82,6 +82,7 @@ class TestThroughputVsPktBridgeWpa2G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pkt142 @@ -129,6 +130,7 @@ class TestThroughputVsPktBridgeWpa2G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pkt256 @@ -176,6 +178,7 @@ class TestThroughputVsPktBridgeWpa2G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pkt512 @@ -223,6 +226,7 @@ class TestThroughputVsPktBridgeWpa2G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pkt1024 @@ -270,6 +274,7 @@ class TestThroughputVsPktBridgeWpa2G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pktMTU @@ -342,7 +347,7 @@ class TestThroughputVsPktBridgeWpa5G(object): """Throughput vs Various Pkt Size Test BRIDGE MODE pytest -m "throughput_vs_pkt and Bridge" """ - + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fiveg @pytest.mark.pkt60 @@ -390,6 +395,7 @@ class TestThroughputVsPktBridgeWpa5G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fiveg @pytest.mark.pkt142 @@ -437,6 +443,7 @@ class TestThroughputVsPktBridgeWpa5G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fiveg @pytest.mark.pkt256 @@ -484,6 +491,7 @@ class TestThroughputVsPktBridgeWpa5G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fiveg @pytest.mark.pkt512 @@ -531,6 +539,7 @@ class TestThroughputVsPktBridgeWpa5G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fiveg @pytest.mark.pkt1024 @@ -578,6 +587,7 @@ class TestThroughputVsPktBridgeWpa5G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fiveg @pytest.mark.pktMTU diff --git a/tests/e2e/basic/performance_tests/throughput_benchmark/throughput_vs_various_pkt_sizes/wpa_security/test_nat_mode.py b/tests/e2e/basic/performance_tests/throughput_benchmark/throughput_vs_various_pkt_sizes/wpa_security/test_nat_mode.py index 41af82f4a..03d26bf0f 100644 --- a/tests/e2e/basic/performance_tests/throughput_benchmark/throughput_vs_various_pkt_sizes/wpa_security/test_nat_mode.py +++ b/tests/e2e/basic/performance_tests/throughput_benchmark/throughput_vs_various_pkt_sizes/wpa_security/test_nat_mode.py @@ -36,6 +36,7 @@ class TestThroughputVsPktNatAWpa2G(object): """Throughput vs Various Pkt Size Test nat mode pytest -m "throughput_vs_pkt and nat" """ + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pkt60 @@ -83,6 +84,7 @@ class TestThroughputVsPktNatAWpa2G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pkt142 @@ -130,6 +132,7 @@ class TestThroughputVsPktNatAWpa2G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pkt256 @@ -177,6 +180,7 @@ class TestThroughputVsPktNatAWpa2G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pkt512 @@ -224,6 +228,7 @@ class TestThroughputVsPktNatAWpa2G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pkt1024 @@ -271,6 +276,7 @@ class TestThroughputVsPktNatAWpa2G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pktMTU @@ -344,6 +350,7 @@ class TestThroughputVsPktNatOpen5G(object): """Throughput vs Various Pkt Size Test nat mode pytest -m "throughput_vs_pkt and nat" """ + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fiveg @pytest.mark.pkt60 @@ -391,6 +398,7 @@ class TestThroughputVsPktNatOpen5G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fiveg @pytest.mark.pkt142 @@ -438,6 +446,7 @@ class TestThroughputVsPktNatOpen5G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fiveg @pytest.mark.pkt256 @@ -485,6 +494,7 @@ class TestThroughputVsPktNatOpen5G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fiveg @pytest.mark.pkt512 @@ -532,6 +542,7 @@ class TestThroughputVsPktNatOpen5G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fiveg @pytest.mark.pkt1024 @@ -579,6 +590,7 @@ class TestThroughputVsPktNatOpen5G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fiveg @pytest.mark.pktMTU diff --git a/tests/e2e/basic/performance_tests/throughput_benchmark/throughput_vs_various_pkt_sizes/wpa_security/test_vlan_mode.py b/tests/e2e/basic/performance_tests/throughput_benchmark/throughput_vs_various_pkt_sizes/wpa_security/test_vlan_mode.py index 922a49b5b..f785ec053 100644 --- a/tests/e2e/basic/performance_tests/throughput_benchmark/throughput_vs_various_pkt_sizes/wpa_security/test_vlan_mode.py +++ b/tests/e2e/basic/performance_tests/throughput_benchmark/throughput_vs_various_pkt_sizes/wpa_security/test_vlan_mode.py @@ -36,6 +36,7 @@ class TestThroughputVsPktVlanWpa2G(object): """Throughput vs Various Pkt Size Test vlan mode pytest -m "throughput_vs_pkt and vlan" """ + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pkt60 @@ -83,6 +84,7 @@ class TestThroughputVsPktVlanWpa2G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pkt142 @@ -130,6 +132,7 @@ class TestThroughputVsPktVlanWpa2G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pkt256 @@ -177,6 +180,7 @@ class TestThroughputVsPktVlanWpa2G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pkt512 @@ -224,6 +228,7 @@ class TestThroughputVsPktVlanWpa2G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pkt1024 @@ -271,6 +276,7 @@ class TestThroughputVsPktVlanWpa2G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.twog @pytest.mark.pktMTU @@ -343,6 +349,7 @@ class TestThroughputVsPktVlan5G(object): """Throughput vs Various Pkt Size Test vlan mode pytest -m "throughput_vs_pkt and vlan" """ + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fivg @pytest.mark.pkt60 @@ -390,6 +397,7 @@ class TestThroughputVsPktVlan5G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fivg @pytest.mark.pkt142 @@ -437,6 +445,7 @@ class TestThroughputVsPktVlan5G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fivg @pytest.mark.pkt256 @@ -484,6 +493,7 @@ class TestThroughputVsPktVlan5G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fivg @pytest.mark.pkt512 @@ -531,6 +541,7 @@ class TestThroughputVsPktVlan5G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fivg @pytest.mark.pkt1024 @@ -578,6 +589,7 @@ class TestThroughputVsPktVlan5G(object): else: assert False + @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2548", name="WIFI-2548") @pytest.mark.wpa_personal @pytest.mark.fivg @pytest.mark.pktMTU diff --git a/tools/ap_tools.py b/tools/ap_tools.py index c7ba9d6d1..c34b9aec2 100644 --- a/tools/ap_tools.py +++ b/tools/ap_tools.py @@ -13,7 +13,6 @@ if "libs" not in sys.path: sys.path.append("../libs/apnos/") import argparse -import paramiko from apnos import APNOS diff --git a/tools/pdu.json b/tools/pdu.json index 4f0afb93d..d4ecff600 100644 --- a/tools/pdu.json +++ b/tools/pdu.json @@ -1,14 +1,473 @@ { - "basic-01": + "basic-01-testing": { "host": "192.168.200.49", "username": "admin", "password": "Lanforge12345!" }, - "basic-02": - { - "host": "192.168.200.49", - "username": "admin", - "password": "Lanforge12345!" + "basic-01": { + "controller": { + "url": "https://wlan-portal-svc-nola-02.cicd.lab.wlan.tip.build", + "username": "support@example.com", + "password": "support", + "version": "1.1.0-SNAPSHOT", + "commit_date": "2021-06-01" + }, + "access_point": [ + { + "model": "ecw5410", + "mode": "wifi5", + "serial": "3c2c99f44e77", + "jumphost": "True", + "ip": "10.28.3.100", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP1", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/ecw5410/trunk/ecw5410-1.2.0-rc2.tar.gz" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.6", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "1.1.wiphy4" + ], + "5G-Radio": [ + "1.1.wiphy5" + ], + "AX-Radio": [ + "1.1.wiphy0", + "1.1.wiphy1", + "1.1.wiphy2", + "1.1.wiphy3" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth3", + "2.4G-Station-Name": "wlan0", + "5G-Station-Name": "wlan1", + "AX-Station-Name": "ax" + } + } + }, + "basic-02": { + "controller": { + "url": "https://wlan-portal-svc-nola-02.cicd.lab.wlan.tip.build", + "username": "support@example.com", + "password": "support", + "version": "1.1.0-SNAPSHOT", + "commit_date": "2021-06-01" + }, + "access_point": [ + { + "model": "eap101", + "mode": "wifi6", + "serial": "34efb6af48db", + "jumphost": "True", + "ip": "10.28.3.100", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP2", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/eap101/trunk/eap101-1.2.0-rc2.tar.gz" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.8", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "1.1.wiphy4" + ], + "5G-Radio": [ + "1.1.wiphy5" + ], + "AX-Radio": [ + "1.1.wiphy0", + "1.1.wiphy1", + "1.1.wiphy2", + "1.1.wiphy3" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth3", + "2.4G-Station-Name": "wlan0", + "5G-Station-Name": "wlan0", + "AX-Station-Name": "ax" + } + } + }, + "basic-03": { + "controller": { + "url": "https://sec-ucentral-qa01.cicd.lab.wlan.tip.build:16001", + "username": "tip@ucentral.com", + "password": "openwifi" + }, + "access_point": [ + { + "model": "ec420", + "mode": "wifi5", + "serial": "001122090801", + "jumphost": "True", + "ip": "127.0.0.1", + "username": "lanforge", + "password": "pumpkin77", + "port": 8833, + "jumphost_tty": "/dev/ttyAP3", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/tplink_ec420/20210728-tplink_ec420-uCentral-trunk-12ad0d5-upgrade.bin" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.10", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "1.1.wiphy4" + ], + "5G-Radio": [ + "1.1.wiphy5" + ], + "AX-Radio": [ + "1.1.wiphy0", + "1.1.wiphy1", + "1.1.wiphy2", + "1.1.wiphy3" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth3", + "2.4G-Station-Name": "sta00", + "5G-Station-Name": "sta10", + "AX-Station-Name": "ax" + } + } + }, + "basic-04": { + "controller": { + "url": "https://sec-ucentral-qa01.cicd.lab.wlan.tip.build:16001", + "username": "tip@ucentral.com", + "password": "openwifi" + }, + "access_point": [ + { + "model": "ecw5211", + "mode": "wifi5", + "serial": "68215fda456d", + "jumphost": "True", + "ip": "10.28.3.100", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP5", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/edgecore_eap102/20210625-edgecore_eap102-uCentral-trunk-4225122-upgrade.bin" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.12", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "1.1.wiphy4" + ], + "5G-Radio": [ + "1.1.wiphy5" + ], + "AX-Radio": [ + "1.1.wiphy0", + "1.1.wiphy1", + "1.1.wiphy2", + "1.1.wiphy3" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth3", + "2.4G-Station-Name": "wlan0", + "5G-Station-Name": "wlan0", + "AX-Station-Name": "ax" + } + } + }, + "basic-05": { + "controller": { + "url": "https://sec-ucentral-qa01.cicd.lab.wlan.tip.build:16001", + "username": "tip@ucentral.com", + "password": "openwifi" + }, + "access_point": [ + { + "model": "wf188n", + "mode": "wifi6", + "serial": "0000c1018812", + "jumphost": "True", + "ip": "10.28.3.103", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP1", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/cig_wf188/20210729-cig_wf188-v2.0.0-rc2-ec3662e-upgrade.bin" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.28", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "1.1.wiphy2" + ], + "5G-Radio": [ + "1.1.wiphy3" + ], + "AX-Radio": [ + "1.1.wiphy0", + "1.1.wiphy1", + "1.1.wiphy2", + "1.1.wiphy3" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth1", + "2.4G-Station-Name": "sta00", + "5G-Station-Name": "sta10", + "AX-Station-Name": "ax" + } + } + }, + "basic-06": { + "controller": { + "url": "https://sec-ucentral-qa01.cicd.lab.wlan.tip.build:16001", + "username": "tip@ucentral.com", + "password": "openwifi" + }, + "access_point": [ + { + "model": "eap102", + "mode": "wifi6", + "serial": "903cb39d6918", + "jumphost": "True", + "ip": "10.28.3.103", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP2", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/edgecore_eap102/20210625-edgecore_eap102-uCentral-trunk-4225122-upgrade.bin" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.30", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "1.1.wiphy0", + "1.1.wiphy2" + ], + "5G-Radio": [ + "1.1.wiphy1", + "1.1.wiphy3" + ], + "AX-Radio": [ + "1.1.wiphy4", + "1.1.wiphy5", + "1.1.wiphy6", + "1.1.wiphy7" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth3", + "2.4G-Station-Name": "wlan0", + "5G-Station-Name": "wlan0", + "AX-Station-Name": "ax" + } + } + }, + "basic-07": { + "controller": { + "url": "https://sec-ucentral-qa01.cicd.lab.wlan.tip.build:16001", + "username": "tip@ucentral.com", + "password": "openwifi" + }, + "access_point": [ + { + "model": "eap101", + "mode": "wifi6", + "serial": "903cb36ae223", + "jumphost": "True", + "ip": "10.28.3.103", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP3", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/edgecore_eap101/20210729-edgecore_eap101-v2.0.0-rc2-02244b8-upgrade.bin" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.32", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "wiphy4" + ], + "5G-Radio": [ + "wiphy5" + ], + "AX-Radio": [ + "wiphy0", + "wiphy1", + "wiphy2", + "wiphy3" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth3", + "2.4G-Station-Name": "sta10", + "5G-Station-Name": "sta00", + "AX-Station-Name": "ax" + } + } + }, + "basic-08": { + "controller": { + "url": "https://sec-ucentral-qa01.cicd.lab.wlan.tip.build:16001", + "username": "tip@ucentral.com", + "password": "openwifi" + }, + "access_point": [ + { + "model": "wf194c", + "mode": "wifi6", + "serial": "089b4bb2f10c", + "jumphost": "True", + "ip": "10.28.3.103", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP5", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/cig_wf194c/20210729-cig_wf194c-v2.0.0-rc2-02244b8-upgrade.bin" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.34", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "1.1.wiphy0", + "1.1.wiphy2" + ], + "5G-Radio": [ + "1.1.wiphy1", + "1.1.wiphy3" + ], + "AX-Radio": [ + "1.1.wiphy4", + "1.1.wiphy5", + "1.1.wiphy6", + "1.1.wiphy7" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth3", + "2.4G-Station-Name": "wlan0", + "5G-Station-Name": "wlan0", + "AX-Station-Name": "ax" + } + } + }, + "mesh": { + "controller": { + "url": "http://wlan-portal-svc-digicert.cicd.lab.wlan.tip.build", + "username": "support@example.com", + "password": "support", + "version": "1.1.0-SNAPSHOT", + "commit_date": "2021-06-01" + }, + "access_point": [ + { + "model": "eap101", + "mode": "wifi6", + "serial": "34efb6af4a7a", + "jumphost": "True", + "ip": "10.28.3.101", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP2", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/eap101/trunk/eap101-1.1.0.tar.gz" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.14", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "wiphy0", + "wiphy2" + ], + "5G-Radio": [ + "wiphy1", + "wiphy3" + ], + "AX-Radio": [ + "wiphy4", + "wiphy5", + "wiphy6", + "wiphy7" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth3", + "2.4G-Station-Name": "wlan0", + "5G-Station-Name": "wlan0", + "AX-Station-Name": "ax" + } + } + }, + "interop": { + "controller": { + "url": "https://wlan-portal-svc-nola-02.cicd.lab.wlan.tip.build", + "username": "support@example.com", + "password": "support", + "version": "19.07-SNAPSHOT", + "commit_date": "2021-06-01" + }, + "access_point": [ + { + "model": "ecw5410", + "mode": "wifi5", + "serial": "68215fd2f78c", + "jumphost": "True", + "ip": "10.28.3.102", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP1", + "version": "https://tip-tip-wlan-cloud-docker-repo.jfrog.io/artifactory/tip-wlan-ap-firmware/ecw5410/dev/ecw5410-2021-07-28-pending-0ec23e8.tar.gz" + } + ], + "traffic_generator": { + "name": "Perfecto", + "details": { + "securityToken": "eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI3NzkzZGM0Ni1jZmU4LTQ4ODMtYjhiOS02ZWFlZGU2OTc2MDkifQ.eyJqdGkiOiJjYjRjYjQzYi05Y2FiLTQxNzQtOTYxYi04MDEwNTZkNDM2MzgiLCJleHAiOjAsIm5iZiI6MCwiaWF0IjoxNjExNTk0NzcxLCJpc3MiOiJodHRwczovL2F1dGgyLnBlcmZlY3RvbW9iaWxlLmNvbS9hdXRoL3JlYWxtcy90aXAtcGVyZmVjdG9tb2JpbGUtY29tIiwiYXVkIjoiaHR0cHM6Ly9hdXRoMi5wZXJmZWN0b21vYmlsZS5jb20vYXV0aC9yZWFsbXMvdGlwLXBlcmZlY3RvbW9iaWxlLWNvbSIsInN1YiI6IjdiNTMwYWUwLTg4MTgtNDdiOS04M2YzLTdmYTBmYjBkZGI0ZSIsInR5cCI6Ik9mZmxpbmUiLCJhenAiOiJvZmZsaW5lLXRva2VuLWdlbmVyYXRvciIsIm5vbmNlIjoiZTRmOTY4NjYtZTE3NS00YzM2LWEyODMtZTQwMmI3M2U5NzhlIiwiYXV0aF90aW1lIjowLCJzZXNzaW9uX3N0YXRlIjoiYWNkNTQ3MTctNzJhZC00MGU3LWI0ZDctZjlkMTAyNDRkNWZlIiwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbIm9mZmxpbmVfYWNjZXNzIiwidW1hX2F1dGhvcml6YXRpb24iXX0sInJlc291cmNlX2FjY2VzcyI6eyJyZXBvcnRpdW0iOnsicm9sZXMiOlsiYWRtaW5pc3RyYXRvciJdfSwiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwidmlldy1wcm9maWxlIl19fSwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSBvZmZsaW5lX2FjY2VzcyBlbWFpbCJ9.SOL-wlZiQ4BoLLfaeIW8QoxJ6xzrgxBjwSiSzkLBPYw", + "perfectoURL": "tip" + } + } } } \ No newline at end of file diff --git a/tools/pdu_v3.py b/tools/pdu_v3.py new file mode 100644 index 000000000..315b58b09 --- /dev/null +++ b/tools/pdu_v3.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python3 +""" +Date: 15-09-2021 +By: Amrit Raj @ Candela Technologies Pvt. ltd. +Note: Please ensure that PDU is powered on + Command line to be used as + python pdu_automation.py --host 192.168.200.49 --user admin --password pass1234 --action on/off/cycle --port all/specific_port_number + Eg 1: python pdu_v3.py --host 192.168.200.49 --user admin --password pass1234 --action off --port 1 + Eg 2: python pdu_v3.py --host 192.168.200.49 --user admin --password pass1234 --action off --port 1,2,3,4 + Eg 3: python pdu_v3.py --host 192.168.200.49 --user admin --password pass1234 --action cycle --port all +""" +import os +import json +import time +import argparse +from typing import Sequence +from typing import Optional + +try: + import dlipower +except: + print('Please wait we are installing DLI Power') + os.system('pip install dlipower') + + +class setup: + try: + def __init__(self, hostname, user, password): + self.hostname = hostname + self.user = user + self.password = password + self.power_switch = dlipower.PowerSwitch(hostname=self.hostname, userid=self.user, password=self.password) + except: + print('PDU device is Off') + + +class switch_on(setup): + def __init__(self, hostname, user, password, port=None): + super().__init__(hostname, user, password) + self.port = port + if self.port != 'all': + try: + port = str(self.port).split(",") + for i in port: + self.power_switch[int(i)-1].state = "ON" + except: + self.power_switch[int(self.port)-1].state = "ON" + else: + for outlet in self.power_switch: + outlet.state = 'ON' + + +class switch_off(setup): + def __init__(self, hostname, user, password, port=None): + super().__init__(hostname, user, password) + self.port = port + if self.port != 'all': + try: + port = str(self.port).split(",") + for i in port: + self.power_switch[int(i) - 1].state = "OFF" + except: + self.power_switch[int(self.port) - 1].state = "OFF" + else: + for outlet in self.power_switch: + outlet.state = 'ON' + + +class print_status(setup): + def __init__(self, hostname, user, password): + super().__init__(hostname, user, password) + print(self.power_switch) + + +def main(argv: Optional[Sequence[str]] = None): + parser = argparse.ArgumentParser() + parser.add_argument('--host', help='Please provide host name eg: 192.168.200.65') + parser.add_argument('--username', help='Please provide username eg: admin') + parser.add_argument('--password', help='Please provide password eg: 1234') + parser.add_argument('--action', help='Switches all Outlets in ON Mode eg: --on or --off\n') + parser.add_argument('--port', help='Please provide port name eg: --port lanforge') + args = parser.parse_args(argv) + dic = vars(args) + # if user enter ports as 1,6,7 + # port = [1,6,7] + # print(dic) + if dic['action'] == 'on': + set = setup(dic['host'], dic['username'], dic['password']) + on = switch_on(dic['host'], dic['username'], dic['password'], dic['port']) + elif dic['action'] == 'off': + set = setup(dic['host'], dic['username'], dic['password']) + # for single in port + off = switch_off(dic['host'], dic['username'], dic['password'], dic['port']) + # off = switch_on(dic['action']) + elif dic['action'] == 'cycle': + set = setup(dic['host'], dic['username'], dic['password']) + on = switch_off(dic['host'], dic['username'], dic['password'], dic['port']) + off = switch_on(dic['host'], dic['username'], dic['password'], dic['port']) + else: + print('Command not found') + + +if __name__ == '__main__': + main() \ No newline at end of file