mirror of
https://github.com/Telecominfraproject/wlan-testing.git
synced 2025-10-31 19:08:01 +00:00
Added Bridge mode fixtures
Signed-off-by: shivamcandela <shivam.thakur@candelatech.com>
This commit is contained in:
@@ -4,13 +4,18 @@
|
||||
1. testbed/ sdk_base_url
|
||||
2. login credentials
|
||||
"""
|
||||
|
||||
import base64
|
||||
import datetime
|
||||
import json
|
||||
import re
|
||||
import ssl
|
||||
import time
|
||||
import urllib
|
||||
|
||||
import requests
|
||||
import swagger_client
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
from testbed_info import SDK_BASE_URLS
|
||||
from testbed_info import LOGIN_CREDENTIALS
|
||||
|
||||
@@ -54,14 +59,14 @@ class ConfigureCloudSDK:
|
||||
|
||||
|
||||
"""
|
||||
Library for cloudsdk generic usages, it instantiate the bearer and credentials.
|
||||
Library for cloudsdk_tests generic usages, it instantiate the bearer and credentials.
|
||||
It provides the connectivity to the cloud.
|
||||
"""
|
||||
|
||||
|
||||
class CloudSDK(ConfigureCloudSDK):
|
||||
"""
|
||||
constructor for cloudsdk library : can be used from pytest framework
|
||||
constructor for cloudsdk_tests library : can be used from pytest framework
|
||||
"""
|
||||
|
||||
def __init__(self, testbed=None, customer_id=None):
|
||||
@@ -123,12 +128,25 @@ class CloudSDK(ConfigureCloudSDK):
|
||||
pagination_context=pagination_context)
|
||||
return equipment_data._items
|
||||
|
||||
def validate_equipment_availability(self, equipment_id=None):
|
||||
data = self.get_equipment_by_customer_id()
|
||||
for i in data:
|
||||
if i._id == equipment_id:
|
||||
return i._id
|
||||
return -1
|
||||
|
||||
def request_ap_reboot(self):
|
||||
pass
|
||||
|
||||
def request_firmware_update(self):
|
||||
pass
|
||||
|
||||
def get_model_name(self, equipment_id=None):
|
||||
if equipment_id is None:
|
||||
return None
|
||||
data = self.equipment_client.get_equipment_by_id(equipment_id=equipment_id)
|
||||
return str(data._details._equipment_model)
|
||||
|
||||
"""
|
||||
Profile Utilities
|
||||
"""
|
||||
@@ -180,6 +198,17 @@ class ProfileUtility:
|
||||
if i._name == profile_name:
|
||||
return i
|
||||
return None
|
||||
def get_profile_by_id(self, profile_id=None):
|
||||
# pagination_context = """{
|
||||
# "model_type": "PaginationContext",
|
||||
# "maxItemsPerPage": 10
|
||||
# }"""
|
||||
profiles = self.profile_client.get_profile_by_id(profile_id=profile_id)
|
||||
print(profiles)
|
||||
# for i in profiles._items:
|
||||
# if i._name == profile_name:
|
||||
# return i
|
||||
# return None
|
||||
|
||||
def get_default_profiles(self):
|
||||
pagination_context = """{
|
||||
@@ -196,7 +225,7 @@ class ProfileUtility:
|
||||
if i._name == "TipWlan-3-Radios":
|
||||
self.default_profiles['equipment_ap_3_radios'] = i
|
||||
if i._name == "TipWlan-2-Radios":
|
||||
self.default_profiles['equipment_ap_3_radios'] = i
|
||||
self.default_profiles['equipment_ap_2_radios'] = i
|
||||
if i._name == "Captive-Portal":
|
||||
self.default_profiles['captive_portal'] = i
|
||||
if i._name == "Radius-Profile":
|
||||
@@ -451,34 +480,145 @@ class JFrogUtility:
|
||||
self.password = credentials["password"]
|
||||
self.jfrog_url = "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/"
|
||||
self.build = "pending"
|
||||
ssl._create_default_https_context = ssl._create_unverified_context
|
||||
|
||||
def list_revisions(self):
|
||||
def get_latest_build(self, model=None):
|
||||
jfrog_url = self.jfrog_url + model + "/dev/"
|
||||
auth = str(
|
||||
base64.b64encode(
|
||||
bytes('%s:%s' % (self.user, self.password), 'utf-8')
|
||||
),
|
||||
'ascii'
|
||||
).strip()
|
||||
headers = {'Authorization': 'Basic ' + auth}
|
||||
|
||||
''' FIND THE LATEST FILE NAME'''
|
||||
# print(url)
|
||||
req = urllib.request.Request(jfrog_url, headers=headers)
|
||||
response = urllib.request.urlopen(req)
|
||||
html = response.read()
|
||||
soup = BeautifulSoup(html, features="html.parser")
|
||||
##find the last pending link on dev
|
||||
last_link = soup.find_all('a', href=re.compile(self.build))[-1]
|
||||
latest_file = last_link['href']
|
||||
latest_fw = latest_file.replace('.tar.gz', '')
|
||||
return latest_fw
|
||||
|
||||
def get_revisions(self, model=None):
|
||||
pass
|
||||
|
||||
def get_latest_build(self):
|
||||
pass
|
||||
|
||||
def create_bridge_profile(get_testbed_name="nola-ext-04"):
|
||||
# SSID and AP name shall be used as testbed_name and mode
|
||||
sdk_client = CloudSDK(testbed=get_testbed_name, customer_id=2)
|
||||
profile_object = ProfileUtility(sdk_client=sdk_client)
|
||||
profile_object.get_default_profiles()
|
||||
profile_object.set_rf_profile()
|
||||
ssid_list = []
|
||||
|
||||
|
||||
profile_data = {
|
||||
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_WPA2_BR'),
|
||||
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_WPA2_BR'),
|
||||
"mode": "BRIDGE",
|
||||
"security_key": "%s-%s" % ("ecw5410", "5G_WPA2_BR")
|
||||
}
|
||||
profile_object.create_wpa2_personal_ssid_profile(profile_data=profile_data, fiveg=False)
|
||||
ssid_list.append(profile_data["profile_name"])
|
||||
profile_data = {
|
||||
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_WPA2_BR'),
|
||||
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_WPA2_BR'),
|
||||
"mode": "BRIDGE",
|
||||
"security_key": "%s-%s" % ("ecw5410", "2G_WPA2_BR")
|
||||
}
|
||||
profile_object.create_wpa2_personal_ssid_profile(profile_data=profile_data, two4g=False)
|
||||
ssid_list.append(profile_data["profile_name"])
|
||||
# Create a wpa2 profile
|
||||
pass
|
||||
profile_data = {
|
||||
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", 'BRIDGE'),
|
||||
}
|
||||
profile_object.set_ap_profile(profile_data=profile_data)
|
||||
profile_object.push_profile_old_method(equipment_id='13')
|
||||
|
||||
# create an equipment ap profile
|
||||
return ssid_list
|
||||
def vif(profile_data=[]):
|
||||
import sys
|
||||
if 'apnos' not in sys.path:
|
||||
sys.path.append(f'../apnos')
|
||||
|
||||
from apnos import APNOS
|
||||
APNOS_CREDENTIAL_DATA = {
|
||||
'jumphost_ip': "192.168.200.80",
|
||||
'jumphost_username': "lanforge",
|
||||
'jumphost_password': "lanforge",
|
||||
'jumphost_port': 22
|
||||
}
|
||||
obj = APNOS(APNOS_CREDENTIAL_DATA)
|
||||
# data = obj.get_vif_config_ssids()
|
||||
cur_time = datetime.datetime.now()
|
||||
print(profile_data)
|
||||
for i in range(18):
|
||||
vif_config = list(obj.get_vif_config_ssids())
|
||||
vif_config.sort()
|
||||
vif_state = list(obj.get_vif_state_ssids())
|
||||
vif_state.sort()
|
||||
profile_data = list(profile_data)
|
||||
profile_data.sort()
|
||||
print("create_bridge_profile: ", profile_data)
|
||||
print("vif config data: ", vif_config)
|
||||
print("vif state data: ", vif_state)
|
||||
if profile_data == vif_config:
|
||||
print("matched")
|
||||
if vif_config == vif_state:
|
||||
status = True
|
||||
print("matched 1")
|
||||
break
|
||||
else:
|
||||
print("matched 2")
|
||||
status = False
|
||||
else:
|
||||
status = False
|
||||
time.sleep(10)
|
||||
def main():
|
||||
# credentials = {
|
||||
# "user": "tip-read",
|
||||
# "password": "tip-read"
|
||||
# }
|
||||
# obj = JFrogUtility(credentials=credentials)
|
||||
# print(obj.get_latest_build(model="ecw5410"))
|
||||
# sdk_client = CloudSDK(testbed="nola-ext-04", customer_id=2)
|
||||
# ap_utils = ProfileUtility(sdk_client=sdk_client)
|
||||
# ap_utils.get_profile_by_id(profile_id=5)
|
||||
# # sdk_client.get_model_name()
|
||||
# sdk_client.disconnect_cloudsdk()
|
||||
cur_time = datetime.datetime.now()
|
||||
data = create_bridge_profile()
|
||||
vif(profile_data=data)
|
||||
print(cur_time)
|
||||
|
||||
if __name__ == "__main__":
|
||||
testbeds = ["nola-01", "nola-02", "nola-04", "nola-ext-01", "nola-ext-02", "nola-ext-03", "nola-ext-04",
|
||||
"nola-ext-05"]
|
||||
for i in testbeds:
|
||||
sdk_client = CloudSDK(testbed=i, customer_id=2)
|
||||
print(sdk_client.get_equipment_by_customer_id())
|
||||
print(sdk_client.portal_ping() is None)
|
||||
break
|
||||
# ap_utils = ProfileUtility(sdk_client=sdk_client)
|
||||
# ap_utils.get_default_profiles()
|
||||
# for j in ap_utils.default_profiles:
|
||||
# print(ap_utils.default_profiles[j]._id)
|
||||
main()
|
||||
# testbeds = ["nola-01", "nola-02", "nola-04", "nola-ext-01", "nola-ext-02", "nola-ext-03", "nola-ext-04",
|
||||
# "nola-ext-05"]
|
||||
# for i in testbeds:
|
||||
# sdk_client = CloudSDK(testbed=i, customer_id=2)
|
||||
# print(sdk_client.get_equipment_by_customer_id())
|
||||
# print(sdk_client.portal_ping() is None)
|
||||
# break
|
||||
# # ap_utils = ProfileUtility(sdk_client=sdk_client)
|
||||
# ap_utils.get_default_profiles()
|
||||
# for j in ap_utils.default_profiles:
|
||||
# print(ap_utils.default_profiles[j]._id)
|
||||
|
||||
# data = sdk_client.get_equipment_by_customer_id()
|
||||
# equipment_ids = []
|
||||
# for i in data:
|
||||
# equipment_ids.append(i)
|
||||
# print(equipment_ids[0]._details._equipment_model)
|
||||
sdk_client.disconnect_cloudsdk()
|
||||
time.sleep(2)
|
||||
# data = sdk_client.get_equipment_by_customer_id()
|
||||
# equipment_ids = []
|
||||
# for i in data:
|
||||
# equipment_ids.append(i)
|
||||
# print(equipment_ids[0]._details._equipment_model)
|
||||
# sdk_client.disconnect_cloudsdk()
|
||||
# time.sleep(2)
|
||||
|
||||
# sdk_client.get_equipment_by_customer_id(customer_id=2)
|
||||
# ap_utils = APUtils(sdk_client=sdk_client)
|
||||
@@ -546,43 +686,3 @@ if __name__ == "__main__":
|
||||
# time.sleep(1)
|
||||
|
||||
# ap_utils.delete_profile(profile_id=ap_utils.profile_ids)
|
||||
|
||||
|
||||
def test_open_ssid():
|
||||
sdk_client = CloudSDK(testbed="nola-ext-04")
|
||||
ap_utils = APUtils(sdk_client=sdk_client)
|
||||
print(sdk_client.configuration.api_key_prefix)
|
||||
ap_utils.select_rf_profile(profile_data=None)
|
||||
profile_data = {
|
||||
"profile_name": "test-ssid-open",
|
||||
"ssid_name": "test_open",
|
||||
"mode": "BRIDGE"
|
||||
}
|
||||
ap_utils.create_open_ssid_profile(profile_data=profile_data)
|
||||
profile_data = {
|
||||
"profile_name": "test-ap-profile",
|
||||
}
|
||||
ap_utils.set_ap_profile(profile_data=profile_data)
|
||||
ap_utils.push_profile_old_method(equipment_id='12')
|
||||
sdk_client.disconnect_cloudsdk()
|
||||
pass
|
||||
|
||||
|
||||
def test_wpa_ssid():
|
||||
pass
|
||||
|
||||
|
||||
def test_wpa2_personal_ssid():
|
||||
pass
|
||||
|
||||
|
||||
def test_wpa3_personal_ssid():
|
||||
pass
|
||||
|
||||
|
||||
def test_wpa2_enterprise_ssid():
|
||||
pass
|
||||
|
||||
|
||||
def test_wpa3_enterprise_ssid():
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user