Skip to content

Commit d610916

Browse files
committed
Merge branch 'support-4.15' into devel
2 parents b4e36c2 + 14f1f77 commit d610916

File tree

5 files changed

+46
-5
lines changed

5 files changed

+46
-5
lines changed

Diff for: osia/installer/clouds/base.py

+23
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@
1717
creation.
1818
It also implements logic to obtain correct specification
1919
for specified installation platform"""
20+
21+
import logging
22+
2023
from abc import abstractmethod, ABC
24+
from subprocess import run
2125
from typing import ClassVar, Optional
2226
from jinja2 import Environment, PackageLoader
27+
from semantic_version import Version, SimpleSpec
2328

2429

2530
class AbstractInstaller(ABC):
@@ -60,6 +65,8 @@ def __init__(self,
6065
self.skip_clean = skip_clean
6166
self.installer = installer
6267
self.enable_fips = enable_fips
68+
self.ocp_version = None
69+
self.network_type = "OVNKubernetes"
6370

6471
@abstractmethod
6572
def acquire_resources(self):
@@ -86,13 +93,29 @@ def get_apps_ip(self):
8693
"""Returns apps ip if dns is supported, None otherwise
8794
"""
8895

96+
def _resolve_version(self):
97+
if self.ocp_version is None:
98+
capture = run([self.installer, "version"], capture_output=True, check=False)
99+
ver_string = capture.stdout.decode("utf-8").splitlines()[0].split(' ')[1]
100+
self.ocp_version = ver_string
101+
logging.info("Resolved installed version as %s", self.ocp_version)
102+
103+
def _resolve_network_type(self):
104+
self._resolve_version()
105+
ver = Version(self.ocp_version)
106+
spec = SimpleSpec('<4.15')
107+
if ver in spec:
108+
logging.debug("Older version of openshift, falling back to OpenShiftSDN")
109+
self.network_type = 'OpenShiftSDN'
110+
89111
def check_clean(self):
90112
"""Method returns if installation is configured to clean resources
91113
on failure."""
92114
return not self.skip_clean
93115

94116
def process_template(self):
95117
"""Method executes creation of install-config.yaml"""
118+
self._resolve_network_type()
96119
with open(self.pull_secret_file) as ps_file:
97120
self.pull_secret = ps_file.read()
98121
with open(self.ssh_key_file) as key_file:

Diff for: osia/installer/templates/install-config-base.yaml.jinja2

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ networking:
4040
- cidr: 10.128.0.0/14
4141
hostPrefix: 23
4242
machineCIDR: {% block networkIp %}{% endblock %}
43-
networkType: OpenShiftSDN
43+
networkType: {{ network_type }}
4444
serviceNetwork:
4545
- 172.30.0.0/16
4646
platform:{% block platform %}{% endblock %}

Diff for: poetry.lock

+17-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pylintrc

+4-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ disable=raw-checker-failed,
7373
unused-private-member,
7474
missing-timeout,
7575
unnecessary-dunder-call,
76-
use-dict-literal
76+
use-dict-literal,
77+
broad-exception-raised #TODO fix this in next release
7778

7879
# Enable the message, report, category or checker with the given id(s). You can
7980
# either give multiple identifier separated by comma (,) or put this option
@@ -506,5 +507,5 @@ valid-metaclass-classmethod-first-arg=cls
506507

507508
# Exceptions that will emit a warning when being caught. Defaults to
508509
# "BaseException, Exception".
509-
overgeneral-exceptions=BaseException,
510-
Exception
510+
overgeneral-exceptions=builtins.BaseException,
511+
builtins.Exception

Diff for: pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ gitpython = "*"
3030
beautifulsoup4 = "*"
3131
coloredlogs = "*"
3232
urllib3 = "<2" # add temporarily to enable dependency resolution in real time
33+
semantic-version = "^2.10.0"
3334

3435
[tool.poetry.dev-dependencies]
3536
flake8 = "*"

0 commit comments

Comments
 (0)