Add fedora support to tripleo-repos
Deprecate --centos-mirror in favour of more generic parameter --mirror but respects it for backwards compatibility. Enable fedora mirrors to be configured with --mirror parameter. Assures that default distro specific mirrors are using the distro parameter. Story: https://tree.taiga.io/project/tripleo-ci-board/task/733 Change-Id: I0c8852a0524b6460b4219d0e91c0f43444905a1f Co-Authored-By: Sorin Sbarnea <ssbarnea@redhat.com>
This commit is contained in:
parent
70e30aa6d3
commit
98a91a87df
@ -35,8 +35,11 @@ INCLUDE_PKGS = ('includepkgs=instack,instack-undercloud,'
|
||||
DEFAULT_OUTPUT_PATH = '/etc/yum.repos.d'
|
||||
DEFAULT_RDO_MIRROR = 'https://trunk.rdoproject.org'
|
||||
RDO_RE = re.compile('baseurl=%s' % DEFAULT_RDO_MIRROR)
|
||||
DEFAULT_CENTOS_MIRROR = 'http://mirror.centos.org'
|
||||
CENTOS_RE = re.compile('baseurl=%s' % DEFAULT_CENTOS_MIRROR)
|
||||
|
||||
DEFAULT_MIRROR_MAP = {
|
||||
'fedora': 'https://mirrors.fedoraproject.org',
|
||||
'centos': 'http://mirror.centos.org'
|
||||
}
|
||||
CEPH_REPO_TEMPLATE = '''
|
||||
[tripleo-centos-ceph-%(ceph_release)s]
|
||||
name=tripleo-centos-ceph-%(ceph_release)s
|
||||
@ -78,6 +81,8 @@ def _parse_args():
|
||||
"centos7 will be used unless you use CLI param to change it." %
|
||||
distro, file=sys.stderr)
|
||||
distro = 'centos7'
|
||||
distro_key = re.sub(r'[0-9]+', '', distro)
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Download and install repos necessary for TripleO. Note '
|
||||
'that some of these repos require yum-plugin-priorities, '
|
||||
@ -108,14 +113,30 @@ def _parse_args():
|
||||
parser.add_argument('-o', '--output-path',
|
||||
default=DEFAULT_OUTPUT_PATH,
|
||||
help='Directory in which to save the selected repos.')
|
||||
parser.add_argument(
|
||||
'--mirror',
|
||||
default=DEFAULT_MIRROR_MAP[distro_key],
|
||||
help='Server from which to install base OS packages. '
|
||||
'Default value is based on distro param.')
|
||||
parser.add_argument('--centos-mirror',
|
||||
default=DEFAULT_CENTOS_MIRROR,
|
||||
help='Server from which to install base CentOS '
|
||||
'packages.')
|
||||
default=None,
|
||||
help='[deprecated] Server from which to install base '
|
||||
'CentOS packages. If mentioned it will be used '
|
||||
'as --mirror for backwards compatibility.')
|
||||
parser.add_argument('--rdo-mirror',
|
||||
default=DEFAULT_RDO_MIRROR,
|
||||
help='Server from which to install RDO packages.')
|
||||
return parser.parse_args()
|
||||
|
||||
args = parser.parse_args()
|
||||
if args.centos_mirror:
|
||||
print("WARNING: --centos-mirror was deprecated in favour of --mirror",
|
||||
file=sys.stderr)
|
||||
args.mirror = args.centos_mirror
|
||||
|
||||
distro_key = re.sub(r'[0-9]+', '', args.distro)
|
||||
args.old_mirror = DEFAULT_MIRROR_MAP[distro_key]
|
||||
|
||||
return args
|
||||
|
||||
|
||||
def _get_repo(path, args):
|
||||
@ -229,7 +250,10 @@ def _inject_mirrors(content, args):
|
||||
handles that by using a regex to swap out the baseurl server.
|
||||
"""
|
||||
new_content = RDO_RE.sub('baseurl=%s' % args.rdo_mirror, content)
|
||||
new_content = CENTOS_RE.sub('baseurl=%s' % args.centos_mirror, new_content)
|
||||
|
||||
r = re.compile('baseurl=%s' % args.old_mirror)
|
||||
new_content = r.sub('baseurl=%s' % args.mirror, new_content)
|
||||
|
||||
return new_content
|
||||
|
||||
|
||||
|
@ -69,7 +69,9 @@ class TestTripleORepos(testtools.TestCase):
|
||||
mock_response.text = '88MPH'
|
||||
mock_get.return_value = mock_response
|
||||
fake_addr = 'http://lone/pine/mall'
|
||||
content = main._get_repo(fake_addr, mock.Mock())
|
||||
args = mock.Mock()
|
||||
args.distro = 'centos'
|
||||
content = main._get_repo(fake_addr, args)
|
||||
self.assertEqual('88MPH', content)
|
||||
mock_get.assert_called_once_with(fake_addr)
|
||||
|
||||
@ -287,6 +289,9 @@ class TestTripleORepos(testtools.TestCase):
|
||||
args.branch = 'master'
|
||||
args.output_path = 'test'
|
||||
args.centos_mirror = 'http://foo'
|
||||
args.old_mirror = 'http://mirror.centos.org'
|
||||
args.mirror = 'http://foo'
|
||||
args.distro = 'centos'
|
||||
args.rdo_mirror = 'http://bar'
|
||||
# Abbrevieated repos to verify the regex works
|
||||
fake_repo = '''
|
||||
@ -397,7 +402,10 @@ baseurl=http://foo/centos/7/virt/$basearch/kvm-common
|
||||
enabled=1
|
||||
'''
|
||||
mock_args = mock.Mock(centos_mirror='http://foo',
|
||||
rdo_mirror='http://bar')
|
||||
mirror='http://foo',
|
||||
rdo_mirror='http://bar',
|
||||
distro='centos',
|
||||
old_mirror='http://mirror.centos.org')
|
||||
result = main._inject_mirrors(start_repo, mock_args)
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
@ -408,7 +416,8 @@ name=delorean
|
||||
baseurl=https://some.mirror.com/centos7/some-repo-hash
|
||||
enabled=1
|
||||
'''
|
||||
mock_args = mock.Mock(rdo_mirror='http://some.mirror.com')
|
||||
mock_args = mock.Mock(rdo_mirror='http://some.mirror.com',
|
||||
distro='centos')
|
||||
# If a user has a mirror whose repos already point at itself then
|
||||
# the _inject_mirrors call should be a noop.
|
||||
self.assertEqual(start_repo, main._inject_mirrors(start_repo,
|
||||
|
Loading…
Reference in New Issue
Block a user