Try to use either docker or podman to obtain nova version

docker command is not linked to podman on some RHOSP environments

Change-Id: Idf9b59ca79c0ec62d2673c87aaeb5d29b3d1ce60
This commit is contained in:
Eduardo Olivares 2021-02-18 19:16:06 +01:00 committed by Federico Ressi
parent 7b1c687310
commit 8d879171cd
1 changed files with 13 additions and 8 deletions

View File

@ -505,11 +505,16 @@ def get_rhosp_version():
def get_nova_version_from_container(): def get_nova_version_from_container():
cmd = 'docker exec -uroot nova_conductor nova-manage --version'
ssh_client = list_openstack_nodes(group='controller')[0].ssh_client ssh_client = list_openstack_nodes(group='controller')[0].ssh_client
return sh.execute(cmd, for container_runtime_cmd in ('docker', 'podman'):
ssh_client=ssh_client, try:
sudo=True).stdout cmd = (container_runtime_cmd +
' exec -uroot nova_conductor nova-manage --version')
return sh.execute(cmd,
ssh_client=ssh_client,
sudo=True).stdout
except sh.ShellCommandFailed:
pass
def get_openstack_version(): def get_openstack_version():
@ -517,9 +522,9 @@ def get_openstack_version():
return get_rhosp_version() return get_rhosp_version()
except (TypeError, sh.ShellCommandFailed): except (TypeError, sh.ShellCommandFailed):
pass pass
try:
nova_version = get_nova_version_from_container() nova_version = get_nova_version_from_container()
except sh.ShellCommandFailed: if nova_version is None:
ssh_client = list_openstack_nodes(group='controller')[0].ssh_client ssh_client = list_openstack_nodes(group='controller')[0].ssh_client
nova_version = sh.execute('nova-manage --version', nova_version = sh.execute('nova-manage --version',
ssh_client=ssh_client, ssh_client=ssh_client,
@ -527,7 +532,7 @@ def get_openstack_version():
os_to_nova_versions = {'13.0.0': '17', # Queens os_to_nova_versions = {'13.0.0': '17', # Queens
'16.0.0': '19', # Stein '16.0.0': '19', # Stein
'16.1.0': '20', # Train '16.1.0': '20', # Train
'17.0.0': '21'} # Ussuri '17.0.0': '22'} # Ussuri
for os_version, nova_major_version in os_to_nova_versions.items(): for os_version, nova_major_version in os_to_nova_versions.items():
if nova_version.split('.')[0] == nova_major_version: if nova_version.split('.')[0] == nova_major_version:
return os_version return os_version