mirror of
https://github.com/Telecominfraproject/wlan-testing.git
synced 2025-10-30 18:38:06 +00:00
This is going to take more work, but getting somewhat closer. Stop using pytest/helpers, they are replaced by libraries. Existing libraries are often taking a command-line-args option as easy way to pass something to various methods. This will have to be resolved to work with the way pytest wants to run. Much hard-coding needs to be removed, and specifically, the 'set profile' logic is completley not working. Need to use library logic that can query the eq-id based on name (and query eq-name based on serial port/ssh, perhaps). Need to resolve how cmd-line can take multiple APs, but each will have different eq-id. Signed-off-by: Ben Greear <greearb@candelatech.com>
63 lines
1.8 KiB
Python
63 lines
1.8 KiB
Python
import ssl
|
|
import base64
|
|
import urllib.request
|
|
from bs4 import BeautifulSoup
|
|
import re
|
|
from ap_ssh import ssh_cli_active_fw
|
|
from lab_ap_info import *
|
|
|
|
|
|
class GetBuild:
|
|
def __init__(self, jfrog_user, jfrog_passwd, build, url=None):
|
|
self.user = jfrog_user
|
|
self.password = jfrog_passwd
|
|
ssl._create_default_https_context = ssl._create_unverified_context
|
|
if url:
|
|
self.jfrog_url = url
|
|
else:
|
|
self.jfrog_url = 'https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/'
|
|
self.build = build
|
|
|
|
def get_user(self):
|
|
return self.user
|
|
|
|
def get_passwd(self):
|
|
return self.password
|
|
|
|
def get_latest_image(self, model, for_build=None):
|
|
|
|
build_name = self.build
|
|
if for_build:
|
|
build_name = for_build
|
|
|
|
url = self.jfrog_url + model + "/dev/"
|
|
print("JfrogHelper::get_latest_image, url: ", url)
|
|
|
|
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(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(build_name))[-1]
|
|
latest_file = last_link['href']
|
|
latest_fw = latest_file.replace('.tar.gz', '')
|
|
return latest_fw
|
|
|
|
def check_latest_fw(self, ap_model=None):
|
|
for model in ap_models:
|
|
if model == ap_model:
|
|
return self.get_latest_image(model)
|
|
else:
|
|
continue
|