rename-channel command
This commit is contained in:
parent
33784ebd31
commit
4f77e08b3f
2 changed files with 30 additions and 0 deletions
16
cli/koji
16
cli/koji
|
|
@ -617,6 +617,22 @@ def handle_remove_host_from_channel(options, session, args):
|
|||
|
||||
session.removeHostFromChannel(host, channel)
|
||||
|
||||
def handle_rename_channel(options, session, args):
|
||||
"[admin] Rename a channel"
|
||||
usage = _("usage: %prog rename-channel [options] old-name new-name")
|
||||
usage += _("\n(Specify the --help global option for a list of other help options)")
|
||||
parser = OptionParser(usage=usage)
|
||||
(options, args) = parser.parse_args(args)
|
||||
if len(args) != 2:
|
||||
parser.error(_("Incorrect number of arguments"))
|
||||
assert False
|
||||
activate_session(session)
|
||||
cinfo = session.getChannel(args[0])
|
||||
if not cinfo:
|
||||
print "No such channel: %s" % args[0]
|
||||
return 1
|
||||
session.renameChannel(args[0], args[1])
|
||||
|
||||
def handle_add_pkg(options, session, args):
|
||||
"[admin] Add a package to the listing for tag"
|
||||
usage = _("usage: %prog add-pkg [options] tag package [package2 ...]")
|
||||
|
|
|
|||
|
|
@ -1871,6 +1871,19 @@ def remove_host_from_channel(hostname, channel_name):
|
|||
c.execute("""DELETE FROM host_channels WHERE host_id = %(host_id)d and channel_id = %(channel_id)d""", locals())
|
||||
context.commit_pending = True
|
||||
|
||||
def rename_channel(old, new):
|
||||
"""Rename a channel"""
|
||||
context.session.assertPerm('admin')
|
||||
if not isinstance(new, basestring):
|
||||
raise koji.GenericError, "new channel name must be a string"
|
||||
cinfo = get_channel(old, strict=True)
|
||||
dup_check = get_channel(new, strict=False)
|
||||
if dup_check:
|
||||
raise koji.GenericError, "channel %(name)s already exists (id=%(id)i)" % dup_check
|
||||
update = UpdateProcessor('channels', clauses=['id=%(id)i'], values=cinfo)
|
||||
update.set(name=new)
|
||||
update.execute()
|
||||
|
||||
def get_ready_hosts():
|
||||
"""Return information about hosts that are ready to build.
|
||||
|
||||
|
|
@ -7720,6 +7733,7 @@ class RootExports(object):
|
|||
editHost = staticmethod(edit_host)
|
||||
addHostToChannel = staticmethod(add_host_to_channel)
|
||||
removeHostFromChannel = staticmethod(remove_host_from_channel)
|
||||
renameChannel = staticmethod(rename_channel)
|
||||
|
||||
def listHosts(self, arches=None, channelID=None, ready=None, enabled=None, userID=None, queryOpts=None):
|
||||
"""Get a list of hosts. "arches" is a list of string architecture
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue