mirror of
https://github.com/Telecominfraproject/wlan-testing.git
synced 2025-11-01 03:17:54 +00:00
deploy cloud controller for uCentral sanity (#171)
This commit is contained in:
225
.github/workflows/uc_sanity.yml
vendored
225
.github/workflows/uc_sanity.yml
vendored
@@ -63,6 +63,83 @@ jobs:
|
|||||||
- name: push docker image
|
- name: push docker image
|
||||||
run: docker push ${{ env.DOCKER_SERVER }}/cloud-sdk-nightly:${{ github.run_id }}
|
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:
|
generate-matrix:
|
||||||
name: generate testbed matrix
|
name: generate testbed matrix
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -76,9 +153,71 @@ jobs:
|
|||||||
TESTBEDS=$(echo $TESTBEDS | sed "s/,/\",\"/g" | sed 's/^/[\"/g' | sed 's/$/\"]/g')
|
TESTBEDS=$(echo $TESTBEDS | sed "s/,/\",\"/g" | sed 's/^/[\"/g' | sed 's/$/\"]/g')
|
||||||
TESTBEDS=$(echo "$TESTBEDS" | jq -c 'map({"testbed":.})')
|
TESTBEDS=$(echo "$TESTBEDS" | jq -c 'map({"testbed":.})')
|
||||||
echo "::set-output name=matrix::{\"include\":${TESTBEDS}}"
|
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:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [ build, generate-matrix ]
|
needs: [ build, generate-matrix, deploy-controller, set-redirector-url ]
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix: ${{ fromJson( needs.generate-matrix.outputs.matrix ) }}
|
matrix: ${{ fromJson( needs.generate-matrix.outputs.matrix ) }}
|
||||||
@@ -106,6 +245,8 @@ jobs:
|
|||||||
cat << EOF > configuration.py
|
cat << EOF > configuration.py
|
||||||
${{ secrets.LAB_CONFIGURATION }}
|
${{ secrets.LAB_CONFIGURATION }}
|
||||||
EOF
|
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
|
kubectl create secret generic configuration --from-file=configuration=./configuration.py
|
||||||
- name: run sanity tests
|
- name: run sanity tests
|
||||||
run: |
|
run: |
|
||||||
@@ -178,6 +319,7 @@ jobs:
|
|||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
kubectl delete ns "${{ steps.namespace.outputs.name }}" --wait=true
|
kubectl delete ns "${{ steps.namespace.outputs.name }}" --wait=true
|
||||||
|
|
||||||
report:
|
report:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [ test, generate-matrix ]
|
needs: [ test, generate-matrix ]
|
||||||
@@ -191,6 +333,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
wget https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/${{ env.ALLURE_CLI_VERSION }}/allure-commandline-${{ env.ALLURE_CLI_VERSION }}.tgz
|
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
|
tar -xzf allure-commandline-${{ env.ALLURE_CLI_VERSION }}.tgz
|
||||||
|
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: allure-results-${{ matrix.testbed }}
|
name: allure-results-${{ matrix.testbed }}
|
||||||
@@ -213,6 +356,7 @@ jobs:
|
|||||||
if [ -e "reports/sanity/${{ matrix.testbed }}/latest" ] ; then
|
if [ -e "reports/sanity/${{ matrix.testbed }}/latest" ] ; then
|
||||||
cp -r reports/sanity/${{ matrix.testbed }}/latest/history/ allure-results/history
|
cp -r reports/sanity/${{ matrix.testbed }}/latest/history/ allure-results/history
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: add report metadata
|
- name: add report metadata
|
||||||
run: |
|
run: |
|
||||||
cat << EOF >> allure-results/environment.properties
|
cat << EOF >> allure-results/environment.properties
|
||||||
@@ -222,6 +366,7 @@ jobs:
|
|||||||
CiRun.Number=${{ github.run_number }}
|
CiRun.Number=${{ github.run_number }}
|
||||||
CiRun.Url=https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
|
CiRun.Url=https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
- name: generate Allure report
|
- name: generate Allure report
|
||||||
run: allure-${{ env.ALLURE_CLI_VERSION }}/bin/allure generate
|
run: allure-${{ env.ALLURE_CLI_VERSION }}/bin/allure generate
|
||||||
|
|
||||||
@@ -240,6 +385,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir -p reports/sanity/${{ matrix.testbed }}
|
mkdir -p reports/sanity/${{ matrix.testbed }}
|
||||||
cp -Tr allure-report reports/sanity/${{ matrix.testbed }}/${{ github.run_number }}
|
cp -Tr allure-report reports/sanity/${{ matrix.testbed }}/${{ github.run_number }}
|
||||||
|
|
||||||
- name: update latest symlink
|
- name: update latest symlink
|
||||||
if: ${{ (github.event.inputs.marker_expression || 'uc_sanity') == 'uc_sanity' }}
|
if: ${{ (github.event.inputs.marker_expression || 'uc_sanity') == 'uc_sanity' }}
|
||||||
working-directory: reports/sanity/${{ matrix.testbed }}
|
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 config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Automated deployment: $(date -u)"
|
git commit -m "Automated deployment: $(date -u)"
|
||||||
|
|
||||||
- name: push
|
- name: push
|
||||||
if: github.ref == 'refs/heads/master'
|
if: github.ref == 'refs/heads/master'
|
||||||
uses: ad-m/github-push-action@v0.6.0
|
uses: ad-m/github-push-action@v0.6.0
|
||||||
@@ -263,10 +410,84 @@ jobs:
|
|||||||
branch: gh-pages
|
branch: gh-pages
|
||||||
directory: reports
|
directory: reports
|
||||||
|
|
||||||
cleanup:
|
delete-docker-image:
|
||||||
needs: [ test ]
|
needs: [ test ]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: always()
|
if: always()
|
||||||
steps:
|
steps:
|
||||||
- name: cleanup Docker image
|
- 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 }}"
|
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
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import random
|
|||||||
import paramiko
|
import paramiko
|
||||||
from scp import SCPClient
|
from scp import SCPClient
|
||||||
import os
|
import os
|
||||||
import allure
|
|
||||||
|
|
||||||
|
|
||||||
class APNOS:
|
class APNOS:
|
||||||
|
|||||||
@@ -34,13 +34,26 @@ class ConfigureController:
|
|||||||
self.access_token = ""
|
self.access_token = ""
|
||||||
# self.session = requests.Session()
|
# self.session = requests.Session()
|
||||||
self.login_resp = self.login()
|
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):
|
def build_uri_sec(self, path):
|
||||||
new_uri = 'https://%s:%d/api/v1/%s' % (self.host.hostname, self.host.port, path)
|
new_uri = 'https://%s:%d/api/v1/%s' % (self.host.hostname, self.host.port, path)
|
||||||
print(new_uri)
|
print(new_uri)
|
||||||
return 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):
|
def build_uri(self, path):
|
||||||
|
|
||||||
new_uri = 'https://%s:%d/api/v1/%s' % (self.gw_host.hostname, self.gw_host.port, 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)
|
print(resp)
|
||||||
self.check_response("GET", resp, self.make_headers(), "", uri)
|
self.check_response("GET", resp, self.make_headers(), "", uri)
|
||||||
services = resp.json()
|
services = resp.json()
|
||||||
print(services["endpoints"][0]["uri"])
|
print(services)
|
||||||
gw_host = urlparse(services["endpoints"][0]["uri"])
|
gw_host = ""
|
||||||
return 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):
|
def logout(self):
|
||||||
uri = self.build_uri_sec('oauth2/%s' % self.access_token)
|
uri = self.build_uri_sec('oauth2/%s' % self.access_token)
|
||||||
@@ -155,6 +174,73 @@ class Controller(ConfigureController):
|
|||||||
return device_info["UUID"]
|
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:
|
class UProfileUtility:
|
||||||
|
|
||||||
def __init__(self, sdk_client=None, controller_data=None):
|
def __init__(self, sdk_client=None, controller_data=None):
|
||||||
@@ -344,7 +430,7 @@ class UProfileUtility:
|
|||||||
for options in ssid_data:
|
for options in ssid_data:
|
||||||
if options == "multi-psk":
|
if options == "multi-psk":
|
||||||
ssid_info[options] = ssid_data[options]
|
ssid_info[options] = ssid_data[options]
|
||||||
print("hi",ssid_info)
|
print("hi", ssid_info)
|
||||||
if options == "rate-limit":
|
if options == "rate-limit":
|
||||||
ssid_info[options] = ssid_data[options]
|
ssid_info[options] = ssid_data[options]
|
||||||
for i in ssid_data["appliedRadios"]:
|
for i in ssid_data["appliedRadios"]:
|
||||||
@@ -435,13 +521,17 @@ if __name__ == '__main__':
|
|||||||
'password': 'openwifi',
|
'password': 'openwifi',
|
||||||
}
|
}
|
||||||
obj = Controller(controller_data=controller)
|
obj = Controller(controller_data=controller)
|
||||||
profile = UProfileUtility(sdk_client=obj)
|
fms = FMSUtils(sdk_client=obj)
|
||||||
profile.set_mode(mode="BRIDGE")
|
# fms.get_device_set()
|
||||||
profile.set_radio_config()
|
# model = fms.get_latest_fw(model="eap102")
|
||||||
ssid = {"ssid_name": "ssid_wpa2_2g", "appliedRadios": ["2G", "5G"], "security": "psk", "security_key": "something",
|
# print(model)
|
||||||
"vlan": 100}
|
# profile = UProfileUtility(sdk_client=obj)
|
||||||
profile.add_ssid(ssid_data=ssid, radius=False)
|
# profile.set_mode(mode="BRIDGE")
|
||||||
profile.push_config(serial_number="903cb39d6918")
|
# profile.set_radio_config()
|
||||||
print(profile.get_ssid_info())
|
# ssid = {"ssid_name": "ssid_wpa2_2g", "appliedRadios": ["2G", "5G"], "security": "psk", "security_key": "something",
|
||||||
# print(obj.get_devices())
|
# "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()
|
obj.logout()
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ if "libs" not in sys.path:
|
|||||||
sys.path.append("../libs/apnos/")
|
sys.path.append("../libs/apnos/")
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import paramiko
|
|
||||||
from apnos import APNOS
|
from apnos import APNOS
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user