pungi-koji: new cmd option '--latest-link-status'
Add a new option 'latest-link-status' to pungi-koji, if this is specified, pungi will only create the latest symbol link to the compose when compose's status matches the specified statuses. The status name is case insensitive. If the option is not specified it will act as before. Example: pungi-koji --target-dir=_composes --config=data/dummy-pungi.conf \ --test --latest-link-status=finished --latest-link-status=finished_incomplete Signed-off-by: Qixiang Wan <qwan@redhat.com>
This commit is contained in:
parent
23e53219eb
commit
79e97dc845
@ -133,6 +133,13 @@ def main():
|
|||||||
dest="no_latest_link",
|
dest="no_latest_link",
|
||||||
help="don't create latest symbol link to this compose"
|
help="don't create latest symbol link to this compose"
|
||||||
)
|
)
|
||||||
|
parser.add_option(
|
||||||
|
"--latest-link-status",
|
||||||
|
metavar="STATUS",
|
||||||
|
action="append",
|
||||||
|
default=[],
|
||||||
|
help="only create latest symbol link to this compose when compose status matches specified status",
|
||||||
|
)
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
"--quiet",
|
"--quiet",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
@ -181,6 +188,7 @@ def main():
|
|||||||
opts.config = os.path.abspath(opts.config)
|
opts.config = os.path.abspath(opts.config)
|
||||||
|
|
||||||
create_latest_link = not opts.no_latest_link
|
create_latest_link = not opts.no_latest_link
|
||||||
|
latest_link_status = opts.latest_link_status or None
|
||||||
|
|
||||||
import kobo.conf
|
import kobo.conf
|
||||||
import kobo.log
|
import kobo.log
|
||||||
@ -234,13 +242,13 @@ def main():
|
|||||||
notifier.compose = compose
|
notifier.compose = compose
|
||||||
COMPOSE = compose
|
COMPOSE = compose
|
||||||
try:
|
try:
|
||||||
run_compose(compose, create_latest_link)
|
run_compose(compose, create_latest_link=create_latest_link, latest_link_status=latest_link_status)
|
||||||
except Exception, ex:
|
except Exception, ex:
|
||||||
compose.log_error("Compose run failed: %s" % ex)
|
compose.log_error("Compose run failed: %s" % ex)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
def run_compose(compose, create_latest_link=True):
|
def run_compose(compose, create_latest_link=True, latest_link_status=None):
|
||||||
import pungi.phases
|
import pungi.phases
|
||||||
import pungi.metadata
|
import pungi.metadata
|
||||||
|
|
||||||
@ -414,8 +422,21 @@ def run_compose(compose, create_latest_link=True):
|
|||||||
test_phase.start()
|
test_phase.start()
|
||||||
test_phase.stop()
|
test_phase.stop()
|
||||||
|
|
||||||
|
compose.write_status("FINISHED")
|
||||||
|
latest_link = False
|
||||||
if create_latest_link:
|
if create_latest_link:
|
||||||
# create a latest symlink
|
if latest_link_status is None:
|
||||||
|
# create latest symbol link by default if latest_link_status is not specified
|
||||||
|
latest_link = True
|
||||||
|
else:
|
||||||
|
latest_link_status = [s.upper() for s in latest_link_status]
|
||||||
|
if compose.get_status() in [s.upper() for s in latest_link_status]:
|
||||||
|
latest_link = True
|
||||||
|
else:
|
||||||
|
compose.log_warning("Compose status (%s) doesn't match with specified latest-link-status (%s), not create latest link."
|
||||||
|
% (compose.get_status(), str(latest_link_status)))
|
||||||
|
|
||||||
|
if latest_link:
|
||||||
compose_dir = os.path.basename(compose.topdir)
|
compose_dir = os.path.basename(compose.topdir)
|
||||||
if len(compose.conf["release_version"].split(".")) == 1:
|
if len(compose.conf["release_version"].split(".")) == 1:
|
||||||
symlink_name = "latest-%s-%s" % (compose.conf["release_short"], compose.conf["release_version"])
|
symlink_name = "latest-%s-%s" % (compose.conf["release_short"], compose.conf["release_version"])
|
||||||
@ -436,7 +457,6 @@ def run_compose(compose, create_latest_link=True):
|
|||||||
compose.log_error("Couldn't create latest symlink: %s" % ex)
|
compose.log_error("Couldn't create latest symlink: %s" % ex)
|
||||||
|
|
||||||
compose.log_info("Compose finished: %s" % compose.topdir)
|
compose.log_info("Compose finished: %s" % compose.topdir)
|
||||||
compose.write_status("FINISHED")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user