Properly check if OpenStack is installed

Now that sysinv-armada integration is already in place, switch
to the proper way to check if OpenStack application is installed.

Tests conducted:
  - Verify that the check fails if the app does not exist or not
    in 'applied' state, succeeds otherwise.

Story: 2003910
Task: 27852

Change-Id: I04b287ae6c507d100cf40de61d0ed4eca762f8e3
Signed-off-by: Tee Ngo <Tee.Ngo@windriver.com>
This commit is contained in:
Tee Ngo 2018-11-23 17:06:51 -05:00
parent f523790ddd
commit 23c5f83235
1 changed files with 7 additions and 9 deletions

View File

@ -57,7 +57,6 @@ from oslo_config import cfg
from sysinv.common import exception
from sysinv.common import constants
from sysinv.helm import common as helm_common
from sysinv.openstack.common import log as logging
from sysinv.openstack.common.gettextutils import _
from oslo_concurrency import lockutils
@ -1810,12 +1809,11 @@ def extract_tarfile(target_dir, tarfile):
def is_openstack_installed(dbapi):
""" Checks whether the OpenStack application is installed. """
# TODO(Bart): When the sysinv/armada integration is complete, this will
# be updated to check the status of the openstack application.
controller_0 = dbapi.ihost_get_by_hostname(constants.CONTROLLER_0_HOSTNAME)
labels = dbapi.label_get_all(hostid=controller_0.id)
for label in labels:
if label.label_key == helm_common.LABEL_CONTROLLER and \
label.label_value == helm_common.LABEL_VALUE_ENABLED:
try:
openstack_app = dbapi.kube_app_get(constants.HELM_APP_OPENSTACK)
if openstack_app.status == constants.APP_APPLY_SUCCESS:
return True
return False
else:
return False
except exception.KubeAppNotFound:
return False