Automatically pick ubuntu interface name on OSP-17
Change-Id: If173ad3c4fe856ae7fc73ee372e5b857973d8a36
This commit is contained in:
@@ -344,8 +344,10 @@ class URLGlanceImageFixture(FileGlanceImageFixture):
|
|||||||
|
|
||||||
image_url: str
|
image_url: str
|
||||||
|
|
||||||
def __init__(self, image_url: typing.Optional[str] = None, **kwargs):
|
def __init__(self,
|
||||||
super(URLGlanceImageFixture, self).__init__(**kwargs)
|
image_url: str = None,
|
||||||
|
**kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
if image_url is None:
|
if image_url is None:
|
||||||
image_url = self.image_url
|
image_url = self.image_url
|
||||||
else:
|
else:
|
||||||
@@ -435,8 +437,11 @@ class CustomizedGlanceImageFixture(URLGlanceImageFixture):
|
|||||||
username: str = ''
|
username: str = ''
|
||||||
password: str = ''
|
password: str = ''
|
||||||
|
|
||||||
|
def _get_customized_suffix(self) -> str:
|
||||||
|
return 'customized'
|
||||||
|
|
||||||
def customize_image_file(self, base_file: str) -> str:
|
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.path.isfile(customized_file):
|
||||||
if (os.stat(base_file).st_mtime_ns <
|
if (os.stat(base_file).st_mtime_ns <
|
||||||
os.stat(customized_file).st_mtime_ns):
|
os.stat(customized_file).st_mtime_ns):
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ def get_images_options():
|
|||||||
cfg.StrOpt('password',
|
cfg.StrOpt('password',
|
||||||
help="Default " + name + " password"),
|
help="Default " + name + " password"),
|
||||||
cfg.StrOpt('interface_name',
|
cfg.StrOpt('interface_name',
|
||||||
help="Default " + name + " interface name"),
|
help="Default " + name + " image interface name"),
|
||||||
cfg.FloatOpt('connection_timeout',
|
cfg.FloatOpt('connection_timeout',
|
||||||
default=None,
|
default=None,
|
||||||
help=("Default " + name +
|
help=("Default " + name +
|
||||||
|
|||||||
@@ -82,6 +82,13 @@ class UbuntuImageFixture(UbuntuMinimalImageFixture,
|
|||||||
- iperf3 server listening on TCP port 5201
|
- 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
|
@property
|
||||||
def firstboot_commands(self) -> typing.List[str]:
|
def firstboot_commands(self) -> typing.List[str]:
|
||||||
return super().firstboot_commands + [
|
return super().firstboot_commands + [
|
||||||
@@ -119,7 +126,23 @@ class UbuntuImageFixture(UbuntuMinimalImageFixture,
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def ethernet_device(self) -> str:
|
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
|
@property
|
||||||
def vlan_id(self) -> int:
|
def vlan_id(self) -> int:
|
||||||
|
|||||||
Reference in New Issue
Block a user