Skip to content

Commit

Permalink
Merge branch 'update/deps' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
mijaros committed Jan 13, 2024
2 parents 2780df0 + ea3ea84 commit 841bdd0
Show file tree
Hide file tree
Showing 6 changed files with 906 additions and 1,001 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ update: setup_poetry
poetry update

clean:
poetry env list | cut -d' ' -f1 | xargs poetry env remove
rm .mk_poetry*
poetry env remove --all
rm -rf .mk_poetry* dist

check: setup_poetry
poetry run flake8 osia --max-line-length 100 --show-source --statistics
Expand All @@ -27,4 +27,4 @@ dist: setup_poetry
release: dist
poetry publish

.PHONY: update clean all check
.PHONY: update clean all check
6 changes: 3 additions & 3 deletions osia/installer/clouds/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import warnings
import logging

from munch import Munch
from openstack.connection import from_config, Connection
from openstack.network.v2.floating_ip import FloatingIP
from openstack.network.v2.port import Port
from openstack.image.v2.image import Image
from openstack.exceptions import SDKException
from osia.installer.clouds.base import AbstractInstaller
Expand Down Expand Up @@ -99,7 +99,7 @@ def _find_fit_network(osp_connection: Connection,
named_networks = {k['name']: k for k in osp_connection.list_networks() if k['name'] in networks}
results = {}
for net_name in networks:
net_avail = osp_connection.network.get_network_ip_availability(named_networks[net_name])
net_avail = osp_connection.network.get_network_ip_availability(named_networks[net_name].id)
subnet_usage = [(subnet['total_ips'], subnet['used_ips'])
for subnet in net_avail.subnet_ip_availability if subnet['ip_version'] == 4]
total_ips, used_ips = [sum(i) for i in zip(*subnet_usage)]
Expand All @@ -108,7 +108,7 @@ def _find_fit_network(osp_connection: Connection,
return named_networks[result]['id'], result


def _find_cluster_ports(osp_connection: Connection, cluster_name: str) -> Munch:
def _find_cluster_ports(osp_connection: Connection, cluster_name: str) -> Port:
port_list = [k for k in osp_connection.list_ports()
if k.name.startswith(cluster_name) and k.name.endswith('ingress-port')]
port = next(iter(port_list), None)
Expand Down
32 changes: 17 additions & 15 deletions osia/installer/downloader/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,41 +36,43 @@
PREVIEW_ROOT = "http://mirror.openshift.com/pub/openshift-v4/{}/clients/ocp-dev-preview/"

VERSION_RE = re.compile(r"^openshift-install-(?P<platform>\w+)"
r"(?P<architecture>-\w+)?-(?P<version>\d+.*)\.tar\.gz")
r"(-(?P<architecture>\w+))?-(?P<version>\d+.*)\.tar\.gz")
EXTRACTION_RE = re.compile(r'.*Extracting tools for .*, may take up to a minute.*')


def _current_platform():
if platform.system() == "Linux" and platform.machine() == "x86_64":
return "linux", "amd64"
if platform.system() == "Linux" and platform.machine() == "arm64":
return "linux", "arm64"
if platform.system() == "Darwin" and platform.machine() == "arm64":
return "mac", "arm64"
if platform.system() == "Darwin" and platform.machine() == "x86_64":
return "mac", None
return "mac", "amd64"
raise Exception(f"Unrecognized platform {platform.system()} {platform.machine()}")


def get_url(directory: str) -> Tuple[Optional[str], Optional[str]]:
def get_url(directory: str, arch: str) -> Tuple[Optional[str], Optional[str]]:
"""Searches the http directory and returns both url to installer
and version.
"""
lst = requests.get(directory, allow_redirects=True)
tree = BeautifulSoup(lst.content, 'html.parser')
links = tree.find_all('a')
installer, version = None, None
os_name, arch = _current_platform()
os_name, local_arch = _current_platform()
for k in links:
match = VERSION_RE.match(k.get('href'))
if match and match.group('platform') == os_name:
if (arch and not match.group('architecture')) \
or (not arch and match.group('architecture')):
continue
installer = lst.url + k.get('href')
version = match.group('version')
if (local_arch == match.group('architecture')) \
or (local_arch == arch and not match.group('architecture')):
installer = lst.url + k.get('href')
version = match.group('version')
break
return installer, version


def get_devel_url(version: str) -> str:
def get_devel_url(version: str, arch: str) -> Tuple[Optional[str], Optional[str]]:
"""
Searches developement sources and returns url to installer
"""
Expand All @@ -83,17 +85,17 @@ def get_devel_url(version: str) -> str:
req = requests.get(BUILD_ROOT + version, allow_redirects=True)
ast = BeautifulSoup(req.content, 'html.parser')
logging.debug('Installer found on page, continuing')
return get_url(req.url)
return get_url(req.url, arch)


def get_prev_url(version, arch):
def get_prev_url(version: str, arch: str) -> Tuple[Optional[str], Optional[str]]:
"""Returns installer url from dev-preview sources"""
return get_url(PREVIEW_ROOT.format(arch) + version)
return get_url(PREVIEW_ROOT.format(arch) + version, arch)


def get_prod_url(version, arch):
def get_prod_url(version: str, arch: str) -> Tuple[Optional[str], Optional[str]]:
"""Returns installer url from production sources"""
return get_url(PROD_ROOT.format(arch) + version)
return get_url(PROD_ROOT.format(arch) + version, arch)


def _get_storage_path(version: str, install_base: str) -> str:
Expand Down
Loading

0 comments on commit 841bdd0

Please sign in to comment.