YUM repositories have a field called 'metalink', which is another
method to specify how to reach the repository data. Kimchi, however, is
unaware of that field.
Allow creating and updating a YUM repository with a metalink value, and
return the field 'config > metalink' when listing a YUM repository.
Fix issue #461 (repositories: Kimchi does not display metalink
information).
Signed-off-by: Crístian Viana <vianac(a)linux.vnet.ibm.com>
---
src/kimchi/API.json | 5 +++++
src/kimchi/i18n.py | 4 +++-
src/kimchi/repositories.py | 27 +++++++++++++++++++++++----
3 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/src/kimchi/API.json b/src/kimchi/API.json
index f507251..50de8c7 100644
--- a/src/kimchi/API.json
+++ b/src/kimchi/API.json
@@ -701,6 +701,11 @@
"description": "URL to a file containing a
list of baseurls",
"type": "string",
"error": "KCHREPOS0007E"
+ },
+ "metalink": {
+ "description": "URL to a metalink file for the
repomd.xml",
+ "type": "string",
+ "error": "KCHREPOS0029E"
}
}
}
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index dc0830a..694f283 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -298,7 +298,7 @@ messages = {
"KCHREPOS0010E": _("GPG key must be a URL pointing to the
ASCII-armored file."),
"KCHREPOS0011E": _("Could not update repository %(repo_id)s."),
"KCHREPOS0012E": _("Repository %(repo_id)s does not exist."),
- "KCHREPOS0013E": _("Specify repository base URL or mirror list in
order to create or update a YUM repository."),
+ "KCHREPOS0013E": _("Specify repository base URL, mirror list or
metalink in order to create or update a YUM repository."),
"KCHREPOS0014E": _("Repository management tool was not recognized for
your system."),
"KCHREPOS0015E": _("Repository %(repo_id)s is already
enabled."),
"KCHREPOS0016E": _("Repository %(repo_id)s is already
disabled."),
@@ -314,6 +314,8 @@ messages = {
"KCHREPOS0026E": _("Unable to add repository. Details:
'%(err)s'"),
"KCHREPOS0027E": _("Unable to remove repository. Details:
'%(err)s'"),
"KCHREPOS0028E": _("Configuration items: '%(items)s' are not
supported by repository manager"),
+ "KCHREPOS0029E": _("Repository metalink must be an http://, ftp:// or
file:// URL."),
+ "KCHREPOS0030E": _("Cannot specify mirrorlist and metalink at the same
time."),
"KCHSNAP0001E": _("Virtual machine '%(vm)s' must be stopped
before creating a snapshot of it."),
"KCHSNAP0002E": _("Unable to create snapshot '%(name)s' on
virtual machine '%(vm)s'. Details: %(err)s"),
diff --git a/src/kimchi/repositories.py b/src/kimchi/repositories.py
index 19c5810..e9fc958 100644
--- a/src/kimchi/repositories.py
+++ b/src/kimchi/repositories.py
@@ -112,7 +112,7 @@ class YumRepo(object):
"""
TYPE = 'yum'
DEFAULT_CONF_DIR = "/etc/yum.repos.d"
- CONFIG_ENTRY = ('repo_name', 'mirrorlist')
+ CONFIG_ENTRY = ('repo_name', 'mirrorlist', 'metalink')
def __init__(self):
self._yb = getattr(__import__('yum'), 'YumBase')
@@ -173,6 +173,7 @@ class YumRepo(object):
info['config']['gpgcheck'] = entry.gpgcheck
info['config']['gpgkey'] = entry.gpgkey
info['config']['mirrorlist'] = entry.mirrorlist or ''
+ info['config']['metalink'] = entry.metalink or ''
return info
def addRepo(self, params):
@@ -184,7 +185,8 @@ class YumRepo(object):
config = params.get('config', {})
mirrorlist = config.get('mirrorlist', '')
- if not baseurl and not mirrorlist:
+ metalink = config.get('metalink', '')
+ if not baseurl and not mirrorlist and not metalink:
raise MissingParameter("KCHREPOS0013E")
if baseurl:
@@ -193,6 +195,12 @@ class YumRepo(object):
if mirrorlist:
validate_repo_url(mirrorlist)
+ if metalink:
+ validate_repo_url(metalink)
+
+ if mirrorlist and metalink:
+ raise InvalidOperation('KCHREPOS0030E')
+
repo_id = params.get('repo_id', None)
if repo_id is None:
repo_id = "kimchi_repo_%s" % str(int(time.time() * 1000))
@@ -206,7 +214,7 @@ class YumRepo(object):
repo_name = config.get('repo_name', repo_id)
repo = {'baseurl': baseurl, 'mirrorlist': mirrorlist,
'name': repo_name, 'gpgcheck': 1,
- 'gpgkey': [], 'enabled': 1}
+ 'gpgkey': [], 'enabled': 1, 'metalink':
metalink}
# write a repo file in the system with repo{} information.
parser = ConfigParser()
@@ -274,6 +282,7 @@ class YumRepo(object):
baseurl = params.get('baseurl', None)
config = params.get('config', {})
mirrorlist = config.get('mirrorlist', None)
+ metalink = config.get('metalink', None)
if baseurl is not None and len(baseurl.strip()) == 0:
baseurl = None
@@ -281,7 +290,10 @@ class YumRepo(object):
if mirrorlist is not None and len(mirrorlist.strip()) == 0:
mirrorlist = None
- if baseurl is None and mirrorlist is None:
+ if metalink is not None and len(metalink.strip()) == 0:
+ metalink = None
+
+ if baseurl is None and mirrorlist is None and metalink is None:
raise MissingParameter("KCHREPOS0013E")
if baseurl is not None:
@@ -292,6 +304,13 @@ class YumRepo(object):
validate_repo_url(mirrorlist)
entry.mirrorlist = mirrorlist
+ if metalink is not None:
+ validate_repo_url(metalink)
+ entry.metalink = metalink
+
+ if mirrorlist and metalink:
+ raise InvalidOperation('KCHREPOS0030E')
+
entry.id = params.get('repo_id', repo_id)
entry.name = config.get('repo_name', entry.name)
entry.gpgcheck = config.get('gpgcheck', entry.gpgcheck)
--
2.1.0