Fixed subscription-manager registration
Optional channel should not be enabled by default and relevant OS channel should be enabled by default. This patch is implementing those features. Priority of plugin serverprep has been changed since we need repositories before we touch any other packstack plugins. Change-Id: Id5a8e89c7bb817c99b398ef0053e1c35a7a21cab Fixes: rhbz#1093482
This commit is contained in:
parent
4956435397
commit
ed5928bdf5
@ -83,6 +83,19 @@ def initConfig(controller):
|
|||||||
"NEED_CONFIRM": False,
|
"NEED_CONFIRM": False,
|
||||||
"CONDITION": False},
|
"CONDITION": False},
|
||||||
|
|
||||||
|
{"CMD_OPTION": "rhn-enable-optional",
|
||||||
|
"USAGE": "To enable RHEL optional repos use value \"y\"",
|
||||||
|
"PROMPT": "To enable RHEL optional repos use value \"y\"",
|
||||||
|
"OPTION_LIST": ["y", "n"],
|
||||||
|
"VALIDATORS": [validators.validate_options],
|
||||||
|
"DEFAULT_VALUE": "y",
|
||||||
|
"MASK_INPUT": False,
|
||||||
|
"LOOSE_VALIDATION": True,
|
||||||
|
"CONF_NAME": "CONFIG_RH_OPTIONAL",
|
||||||
|
"USE_DEFAULT": False,
|
||||||
|
"NEED_CONFIRM": False,
|
||||||
|
"CONDITION": False},
|
||||||
|
|
||||||
{"CMD_OPTION": "rhn-satellite-server",
|
{"CMD_OPTION": "rhn-satellite-server",
|
||||||
"USAGE": ("To subscribe each server with RHN Satellite,fill "
|
"USAGE": ("To subscribe each server with RHN Satellite,fill "
|
||||||
"Satellite's URL here. Note that either satellite's "
|
"Satellite's URL here. Note that either satellite's "
|
||||||
@ -346,10 +359,11 @@ def run_rhn_reg(host, server_url, username=None, password=None,
|
|||||||
server.execute(mask_list=mask)
|
server.execute(mask_list=mask)
|
||||||
|
|
||||||
|
|
||||||
def run_rhsm_reg(host, username, password):
|
def run_rhsm_reg(config, host, username, password):
|
||||||
"""
|
"""
|
||||||
Registers given host to Red Hat Repositories via subscription manager.
|
Registers given host to Red Hat Repositories via subscription manager.
|
||||||
"""
|
"""
|
||||||
|
releasever = config['HOST_DETAILS'][host]['release'].split('.')[0]
|
||||||
server = utils.ScriptRunner(host)
|
server = utils.ScriptRunner(host)
|
||||||
|
|
||||||
# register host
|
# register host
|
||||||
@ -360,12 +374,16 @@ def run_rhsm_reg(host, username, password):
|
|||||||
# subscribe to required channel
|
# subscribe to required channel
|
||||||
cmd = ('subscription-manager list --consumed | grep -i openstack || '
|
cmd = ('subscription-manager list --consumed | grep -i openstack || '
|
||||||
'subscription-manager subscribe --pool %s')
|
'subscription-manager subscribe --pool %s')
|
||||||
pool = ("$(subscription-manager list --available | "
|
pool = ("$(subscription-manager list --available"
|
||||||
"grep -e 'Red Hat OpenStack' -m 1 -A 2 | grep 'Pool Id' | "
|
" | grep -e -m1 -A15 'Red Hat Enterprise Linux OpenStack Platform'"
|
||||||
"awk '{print $3}')")
|
" | grep -i 'Pool ID:' | awk '{print $3}')")
|
||||||
server.append(cmd % pool)
|
server.append(cmd % pool)
|
||||||
|
|
||||||
|
if config['CONFIG_RH_OPTIONAL'] == 'y':
|
||||||
server.append("subscription-manager repos "
|
server.append("subscription-manager repos "
|
||||||
"--enable rhel-6-server-optional-rpms")
|
"--enable rhel-%s-server-optional-rpms" % releasever)
|
||||||
|
server.append("subscription-manager repos "
|
||||||
|
"--enable rhel-%s-server-openstack-5.0-rpms" % releasever)
|
||||||
|
|
||||||
server.append("yum clean all")
|
server.append("yum clean all")
|
||||||
server.append("rpm -q --whatprovides yum-utils || "
|
server.append("rpm -q --whatprovides yum-utils || "
|
||||||
@ -507,7 +525,7 @@ def server_prep(config, messages):
|
|||||||
for hostname in filtered_hosts(config):
|
for hostname in filtered_hosts(config):
|
||||||
# Subscribe to Red Hat Repositories if configured
|
# Subscribe to Red Hat Repositories if configured
|
||||||
if rh_username:
|
if rh_username:
|
||||||
run_rhsm_reg(hostname, rh_username, rh_password)
|
run_rhsm_reg(config, hostname, rh_username, rh_password)
|
||||||
|
|
||||||
# Subscribe to RHN Satellite if configured
|
# Subscribe to RHN Satellite if configured
|
||||||
if sat_url and hostname not in sat_registered:
|
if sat_url and hostname not in sat_registered:
|
@ -18,11 +18,9 @@ import os
|
|||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from test_base import PackstackTestCaseMixin
|
from test_base import PackstackTestCaseMixin
|
||||||
from packstack.plugins import serverprep_949
|
from packstack.plugins import serverprep_001
|
||||||
from packstack.installer.setup_controller import Controller
|
from packstack.installer.setup_controller import Controller
|
||||||
|
|
||||||
serverprep_949.controller = Controller()
|
|
||||||
|
|
||||||
|
|
||||||
class OSPluginUtilsTestCase(PackstackTestCaseMixin, TestCase):
|
class OSPluginUtilsTestCase(PackstackTestCaseMixin, TestCase):
|
||||||
def test_rhn_creds_quoted(self):
|
def test_rhn_creds_quoted(self):
|
||||||
@ -30,30 +28,30 @@ class OSPluginUtilsTestCase(PackstackTestCaseMixin, TestCase):
|
|||||||
|
|
||||||
# On non-RHEL, the CONFIG_{RH,SATELLITE} options are never set,
|
# On non-RHEL, the CONFIG_{RH,SATELLITE} options are never set,
|
||||||
# i.e. this test would always fail. Therefore, only run it on RHEL.
|
# i.e. this test would always fail. Therefore, only run it on RHEL.
|
||||||
if not serverprep_949.is_rhel():
|
if not serverprep_001.is_rhel():
|
||||||
return
|
return
|
||||||
|
|
||||||
password = "dasd|'asda%><?"
|
password = "dasd|'asda%><?"
|
||||||
|
|
||||||
serverprep_949.controller.CONF["CONFIG_KEYSTONE_HOST"] = "1.2.3.4"
|
serverprep_001.controller.CONF["CONFIG_KEYSTONE_HOST"] = "1.2.3.4"
|
||||||
serverprep_949.controller.CONF["CONFIG_USE_EPEL"] = "n"
|
serverprep_001.controller.CONF["CONFIG_USE_EPEL"] = "n"
|
||||||
serverprep_949.controller.CONF["CONFIG_REPO"] = ""
|
serverprep_001.controller.CONF["CONFIG_REPO"] = ""
|
||||||
serverprep_949.controller.CONF["CONFIG_RH_USER"] = "testuser"
|
serverprep_001.controller.CONF["CONFIG_RH_USER"] = "testuser"
|
||||||
serverprep_949.controller.CONF["CONFIG_RH_PW"] = password
|
serverprep_001.controller.CONF["CONFIG_RH_PW"] = password
|
||||||
serverprep_949.controller.CONF["CONFIG_RH_BETA_REPO"] = "n"
|
serverprep_001.controller.CONF["CONFIG_RH_BETA_REPO"] = "n"
|
||||||
|
|
||||||
serverprep_949.controller.CONF["CONFIG_SATELLITE_FLAGS"] = ""
|
serverprep_001.controller.CONF["CONFIG_SATELLITE_FLAGS"] = ""
|
||||||
serverprep_949.controller.CONF["CONFIG_SATELLITE_URL"] = ""
|
serverprep_001.controller.CONF["CONFIG_SATELLITE_URL"] = ""
|
||||||
serverprep_949.controller.CONF["CONFIG_SATELLITE_USER"] = ""
|
serverprep_001.controller.CONF["CONFIG_SATELLITE_USER"] = ""
|
||||||
serverprep_949.controller.CONF["CONFIG_SATELLITE_PW"] = ""
|
serverprep_001.controller.CONF["CONFIG_SATELLITE_PW"] = ""
|
||||||
serverprep_949.controller.CONF["CONFIG_SATELLITE_CACERT"] = ""
|
serverprep_001.controller.CONF["CONFIG_SATELLITE_CACERT"] = ""
|
||||||
serverprep_949.controller.CONF["CONFIG_SATELLITE_AKEY"] = ""
|
serverprep_001.controller.CONF["CONFIG_SATELLITE_AKEY"] = ""
|
||||||
serverprep_949.controller.CONF["CONFIG_SATELLITE_PROFILE"] = ""
|
serverprep_001.controller.CONF["CONFIG_SATELLITE_PROFILE"] = ""
|
||||||
serverprep_949.controller.CONF["CONFIG_SATELLITE_PROXY"] = ""
|
serverprep_001.controller.CONF["CONFIG_SATELLITE_PROXY"] = ""
|
||||||
serverprep_949.controller.CONF["CONFIG_SATELLITE_PROXY_USER"] = ""
|
serverprep_001.controller.CONF["CONFIG_SATELLITE_PROXY_USER"] = ""
|
||||||
serverprep_949.controller.CONF["CONFIG_SATELLITE_PROXY_PW"] = ""
|
serverprep_001.controller.CONF["CONFIG_SATELLITE_PROXY_PW"] = ""
|
||||||
|
|
||||||
serverprep_949.serverprep(serverprep_949.controller.CONF)
|
serverprep_001.serverprep(serverprep_001.controller.CONF)
|
||||||
|
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
self.fake_popen.data.find('--password="%s"' % password), -1
|
self.fake_popen.data.find('--password="%s"' % password), -1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user