Only ask RHEL specific questions when run on RHEL

Putting the RHEL specific questions into a separate group and
adding a is_rhel pre-condition so non-RHEL users won't get bugged
in interactive mode.

Also, one of the tests will no longer make sense on non-RHEL
platforms and has therefore been disarmed on those. Since all tests
are always also run on RHEL, this should be of no concern.

Change-Id: I7f39762dd9ad60545bff993ec99c8e4acfe10e2e
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=921545
This commit is contained in:
Sandro Mathys 2013-04-03 11:50:49 +02:00
parent 43a6642b3d
commit 503ea9022b
2 changed files with 44 additions and 20 deletions

View File

@ -6,6 +6,7 @@ import os
import uuid import uuid
import logging import logging
import datetime import datetime
import platform
from packstack.installer import basedefs from packstack.installer import basedefs
from packstack.installer import common_utils as utils from packstack.installer import common_utils as utils
@ -53,8 +54,9 @@ def initConfig(controllerObject):
"CONF_NAME" : "CONFIG_REPO", "CONF_NAME" : "CONFIG_REPO",
"USE_DEFAULT" : False, "USE_DEFAULT" : False,
"NEED_CONFIRM" : False, "NEED_CONFIRM" : False,
"CONDITION" : False }, "CONDITION" : False }],
"RHEL": [
{"CMD_OPTION" : "rh-username", {"CMD_OPTION" : "rh-username",
"USAGE" : "To subscribe each server with Red Hat subscription manager, include this with CONFIG_RH_PW", "USAGE" : "To subscribe each server with Red Hat subscription manager, include this with CONFIG_RH_PW",
"PROMPT" : "To subscribe each server to Red Hat enter a username here", "PROMPT" : "To subscribe each server to Red Hat enter a username here",
@ -227,6 +229,9 @@ def initConfig(controllerObject):
"NEED_CONFIRM" : False, "NEED_CONFIRM" : False,
"CONDITION" : False }]} "CONDITION" : False }]}
def is_on_rhel(config):
return is_rhel()
def filled_satellite(config): def filled_satellite(config):
return bool(config.get('CONFIG_SATELLITE_URL')) return bool(config.get('CONFIG_SATELLITE_URL'))
@ -241,6 +246,13 @@ def initConfig(controllerObject):
"POST_CONDITION" : False, "POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True}, "POST_CONDITION_MATCH" : True},
{"GROUP_NAME" : "RHEL",
"DESCRIPTION" : "RHEL config",
"PRE_CONDITION" : is_on_rhel,
"PRE_CONDITION_MATCH" : True,
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True},
{"GROUP_NAME" : "SATELLITE", {"GROUP_NAME" : "SATELLITE",
"DESCRIPTION" : "RHN Satellite config", "DESCRIPTION" : "RHN Satellite config",
"PRE_CONDITION" : filled_satellite, "PRE_CONDITION" : filled_satellite,
@ -261,6 +273,10 @@ def initConfig(controllerObject):
controller.addGroup(group, paramList) controller.addGroup(group, paramList)
def is_rhel():
return 'Red Hat Enterprise Linux' in platform.linux_distribution()[0]
def run_rhn_reg(host, server_url, username=None, password=None, def run_rhn_reg(host, server_url, username=None, password=None,
cacert=None, activation_key=None, profile_name=None, cacert=None, activation_key=None, profile_name=None,
proxy_host=None, proxy_user=None, proxy_pass=None, proxy_host=None, proxy_user=None, proxy_pass=None,
@ -362,6 +378,9 @@ def initSequences(controller):
def serverprep(): def serverprep():
config = controller.CONF config = controller.CONF
rh_username = None
sat_url = None
if is_rhel():
rh_username = config["CONFIG_RH_USER"].strip() rh_username = config["CONFIG_RH_USER"].strip()
rh_password = config["CONFIG_RH_PW"].strip() rh_password = config["CONFIG_RH_PW"].strip()
@ -417,7 +436,7 @@ def serverprep():
# If RHOS has been installed we can diable EPEL when installing openstack-utils # If RHOS has been installed we can diable EPEL when installing openstack-utils
yum_opts = "" yum_opts = ""
if config["CONFIG_RH_USER"].strip(): if rh_username:
yum_opts += "--disablerepo='epel*'" yum_opts += "--disablerepo='epel*'"
server.append("rpm -q epel-release && " server.append("rpm -q epel-release && "

View File

@ -28,6 +28,11 @@ class OSPluginUtilsTestCase(PackstackTestCaseMixin, TestCase):
def test_rhn_creds_quoted(self): def test_rhn_creds_quoted(self):
"""Make sure RHN password is quoted""" """Make sure RHN password is quoted"""
# On non-RHEL, the CONFIG_{RH,SATELLITE} options are never set,
# i.e. this test would always fail. Therefore, only run it on RHEL.
if not serverprep_901.is_rhel():
return
password = "dasd|'asda%><?" password = "dasd|'asda%><?"
serverprep_901.controller.CONF["CONFIG_KEYSTONE_HOST"] = "1.2.3.4" serverprep_901.controller.CONF["CONFIG_KEYSTONE_HOST"] = "1.2.3.4"