add getVersion and listPlugin commands and update replicate command
The replication command string changed after replication became a plugin in gerrit. This patch adds a getVersion[1] and a listPlugins[2] command to gerritlib. The listPlugin command is used to determine the correct replication string to execute in the replication command. [1] Only available on gerrit version >= 2.6 [2] Only available on gerrit version >= 2.5 Closes-Bug: #1273891 Partial-Bug: #1082781 Change-Id: I966037851b3f27536f415230edd1ae4e710321fb
This commit is contained in:
parent
996a04dbf6
commit
d0bca22df9
@ -165,6 +165,7 @@ class Gerrit(object):
|
||||
self.keyfile = keyfile
|
||||
self.watcher_thread = None
|
||||
self.event_queue = None
|
||||
self.installed_plugins = None
|
||||
|
||||
def startWatching(self, connection_attempts=-1, retry_delay=5):
|
||||
self.event_queue = Queue.Queue()
|
||||
@ -209,8 +210,32 @@ class Gerrit(object):
|
||||
out, err = self._ssh(cmd)
|
||||
return filter(None, out.split('\n'))
|
||||
|
||||
def listPlugins(self):
|
||||
plugins = self.getPlugins()
|
||||
plugin_names = plugins.keys()
|
||||
return plugin_names
|
||||
|
||||
# get installed plugins info returned is (name, version, status, file)
|
||||
def getPlugins(self):
|
||||
# command only available on gerrit verion >= 2.5
|
||||
cmd = 'gerrit plugin ls --format json'
|
||||
out, err = self._ssh(cmd)
|
||||
return json.loads(out)
|
||||
|
||||
def getVersion(self):
|
||||
# command only available on gerrit verion >= 2.6
|
||||
cmd = 'gerrit version'
|
||||
out, err = self._ssh(cmd)
|
||||
out = out.split(' ')[2]
|
||||
return out.strip('\n')
|
||||
|
||||
def replicate(self, project='--all'):
|
||||
cmd = 'gerrit replicate %s' % project
|
||||
cmd = 'replication start %s' % project
|
||||
if self.installed_plugins is None:
|
||||
try:
|
||||
self.installed_plugins = self.listPlugins()
|
||||
except Exception:
|
||||
cmd = 'gerrit replicate %s' % project
|
||||
out, err = self._ssh(cmd)
|
||||
return out.split('\n')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user