Automatically pick ubuntu interface name on OSP-17

Change-Id: If173ad3c4fe856ae7fc73ee372e5b857973d8a36
This commit is contained in:
Federico Ressi
2022-07-15 12:22:44 +02:00
parent b46dd592b4
commit ebebf24d59
3 changed files with 33 additions and 5 deletions

View File

@@ -344,8 +344,10 @@ class URLGlanceImageFixture(FileGlanceImageFixture):
image_url: str
def __init__(self, image_url: typing.Optional[str] = None, **kwargs):
super(URLGlanceImageFixture, self).__init__(**kwargs)
def __init__(self,
image_url: str = None,
**kwargs):
super().__init__(**kwargs)
if image_url is None:
image_url = self.image_url
else:
@@ -435,8 +437,11 @@ class CustomizedGlanceImageFixture(URLGlanceImageFixture):
username: str = ''
password: str = ''
def _get_customized_suffix(self) -> str:
return 'customized'
def customize_image_file(self, base_file: str) -> str:
customized_file = base_file + '.1'
customized_file = f'{base_file}-{self._get_customized_suffix()}'
if os.path.isfile(customized_file):
if (os.stat(base_file).st_mtime_ns <
os.stat(customized_file).st_mtime_ns):

View File

@@ -63,7 +63,7 @@ def get_images_options():
cfg.StrOpt('password',
help="Default " + name + " password"),
cfg.StrOpt('interface_name',
help="Default " + name + " interface name"),
help="Default " + name + " image interface name"),
cfg.FloatOpt('connection_timeout',
default=None,
help=("Default " + name +

View File

@@ -82,6 +82,13 @@ class UbuntuImageFixture(UbuntuMinimalImageFixture,
- iperf3 server listening on TCP port 5201
"""
def __init__(self,
image_url: str = None,
ethernet_devide: str = None,
**kwargs):
super().__init__(image_url=image_url, **kwargs)
self._ethernet_device = ethernet_devide
@property
def firstboot_commands(self) -> typing.List[str]:
return super().firstboot_commands + [
@@ -119,7 +126,23 @@ class UbuntuImageFixture(UbuntuMinimalImageFixture,
@property
def ethernet_device(self) -> str:
return CONF.tobiko.ubuntu.interface_name or 'ens3'
if self._ethernet_device is None:
self._ethernet_device = self._get_ethernet_device()
return self._ethernet_device
@staticmethod
def _get_ethernet_device() -> str:
ethernet_device = CONF.tobiko.ubuntu.interface_name
if ethernet_device is None:
from tobiko import tripleo
if tripleo.has_overcloud(min_version='17.0'):
ethernet_device = 'enp3s0'
else:
ethernet_device = 'ens3'
return ethernet_device
def _get_customized_suffix(self) -> str:
return f'{super()._get_customized_suffix()}-{self.ethernet_device}'
@property
def vlan_id(self) -> int: