Select proper release ID when updating defaults
fuel-package-updates now searches for release ID that matches version and operating_system of a release in Nailgun. Fixed spelling of mos-updates repo to match default. Change-Id: I1e5b54290b44f40dcf13badb737565ee5ce2114a Closes-Bug: #1461546
This commit is contained in:
parent
0c53b2a744
commit
4b493817e8
@ -299,6 +299,19 @@ class NailgunClient(object):
|
|||||||
return self.client.put(
|
return self.client.put(
|
||||||
"/api/releases/{0}/".format(release_id), attrs)
|
"/api/releases/{0}/".format(release_id), attrs)
|
||||||
|
|
||||||
|
@json_parse
|
||||||
|
def get_releases(self):
|
||||||
|
return self.client.get("/api/releases/")
|
||||||
|
|
||||||
|
def get_release_id(self, operating_system, release_version):
|
||||||
|
for release in self.get_releases():
|
||||||
|
if release["version"] == release_version:
|
||||||
|
if release["operating_system"].lower() == \
|
||||||
|
operating_system.lower():
|
||||||
|
return release["id"]
|
||||||
|
logger.error("Release not found for {0} - {1}".format(operating_system,
|
||||||
|
release_version))
|
||||||
|
|
||||||
|
|
||||||
class UpdatePackagesException(Exception):
|
class UpdatePackagesException(Exception):
|
||||||
pass
|
pass
|
||||||
@ -434,7 +447,7 @@ def get_centos_repos(repopath, ip, httproot, port, baseurl=None):
|
|||||||
repopath=repopath.replace(httproot, ''))
|
repopath=repopath.replace(httproot, ''))
|
||||||
repoentry = {
|
repoentry = {
|
||||||
"type": "rpm",
|
"type": "rpm",
|
||||||
"name": "MOS-Updates",
|
"name": "mos-updates",
|
||||||
"uri": repourl,
|
"uri": repourl,
|
||||||
"priority": 20}
|
"priority": 20}
|
||||||
return [repoentry]
|
return [repoentry]
|
||||||
@ -475,7 +488,8 @@ def show_env_conf(repos, showuri=False, ip="10.20.0.2"):
|
|||||||
print(reindent(yaml.dump(yamldata, default_flow_style=False), spaces))
|
print(reindent(yaml.dump(yamldata, default_flow_style=False), spaces))
|
||||||
|
|
||||||
|
|
||||||
def update_env_conf(ip, distro, repos, env_id=None, makedefault=False):
|
def update_env_conf(ip, distro, release, repos, env_id=None,
|
||||||
|
makedefault=False):
|
||||||
fwc = FuelWebClient(ip)
|
fwc = FuelWebClient(ip)
|
||||||
|
|
||||||
if env_id is not None:
|
if env_id is not None:
|
||||||
@ -483,12 +497,11 @@ def update_env_conf(ip, distro, repos, env_id=None, makedefault=False):
|
|||||||
fwc.update_cluster_repos(env_id, repos)
|
fwc.update_cluster_repos(env_id, repos)
|
||||||
|
|
||||||
if makedefault:
|
if makedefault:
|
||||||
release_id = None
|
#ubuntu-baseos updates ubuntu release
|
||||||
if DISTROS.ubuntu in distro:
|
if DISTROS.ubuntu in distro:
|
||||||
release_id = 2
|
distro = DISTROS.ubuntu
|
||||||
elif distro == DISTROS.centos:
|
release_id = fwc.client.get_release_id(distro, release)
|
||||||
release_id = 1
|
logger.info("Updating release ID {0}".format(release_id))
|
||||||
|
|
||||||
if release_id is not None:
|
if release_id is not None:
|
||||||
fwc.update_default_repos(release_id, repos)
|
fwc.update_default_repos(release_id, repos)
|
||||||
|
|
||||||
@ -656,8 +669,8 @@ def main():
|
|||||||
if options.admin_pass:
|
if options.admin_pass:
|
||||||
KEYSTONE_CREDS['password'] = options.admin_pass
|
KEYSTONE_CREDS['password'] = options.admin_pass
|
||||||
if options.apply:
|
if options.apply:
|
||||||
update_env_conf(options.ip, options.distro, repos, options.env,
|
update_env_conf(options.ip, options.distro, options.release, repos,
|
||||||
options.makedefault)
|
options.env, options.makedefault)
|
||||||
else:
|
else:
|
||||||
show_env_conf(repos, options.showuri, options.ip)
|
show_env_conf(repos, options.showuri, options.ip)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user