New urllib3 and python requests break python docker-compose. Pin
requests back which should use an older urllib3. Hopefully this
fixes docker-compose.
Note this should probably only be used as a temporary workaround. A
more permanent fix should change the way we install docker-compose.
Also stop relying on six since it's no longer available and we
dropped Python 2.7 support quite some time back anyway.
Clean up some things in tox.ini which regressed in Tox v4.
Co-Authored-By: Clark Boylan <cboylan@sapwetik.org>
Change-Id: I69a7ba09f737130a403f0657708877ce986f751c
In Gerrit 2.14 the -q flag to ls-groups was deprecated in favor of -g.
At some point between 2.14 and 3.2 the -q support was removed entirely.
This change checks the gerrit version then uses the appropriate flag for
querying a group based on that.
We also add more robust testing to check creation of groups with spaces
in their names. We also check that if an acl is updated without group
changes that we don't try to recreate the group and get the group uuid
successfully.
Change-Id: I58c0aa2b496bcd792c8f4bc7db89b08cefa3af3d
When the new Opendev 3.2 Gerrit closes the SSH connection, gerritlib
goes into a hard loop. Either this has never really worked, or our
new version of gerrit closes the SSH connection differently and
triggers this.
Currently the _read() function in this code interprets a 0 read as
data and continues the event loop. This means the _listen() function
never exits. The poll() keeps returning that there is a POLLIN event
and the _read() function keeps reading the empty FD.
Modify this to set the state to DISCONNECTED for a blank read.
Additionally improve the error message if we see invalid data (which
shouldn't happen). Insert a short-circuit in the listen to check if
the state has switched to DISCONNECTED and exit the loop in that case.
Change-Id: I46849bcbfc3a0d409baa654867018994ce717481
Fixed bug which prevented use on newer version of python as we
incorrectly checked event value against the bitmask.
Also improves exception by included value of the event in it.
Change-Id: I49f41d2555f53f2377c32c7626e1350c4f42b8de
Previous code was not allowing use of Gerrit without hardcoded infinite
retries inside Gerrit constructor, meaning that wrong credentials
would create an endless loop which gerritlib consumer could not
prevent.
This allows client to specify number of attempts and delay before
a failure is returned.
Change-Id: I5bd14a14539a2705babb9f9922c800383031c6ac
Clients using gerritlib behind NAT/firewall
can be stuck when the NAT/firewall discard
packets belong to the TCP connection after extended
silent periods thinking the connection is dead.
This change allows clients using gerritlib to set
keep alive interval to a non zero value. This will
enable TCP keep alive packets to be sent in
configured intervals keeping the TCP connections alive.
Change-Id: I588706bb51ce41810cd2243f4969763d193d1d55
This new functiona argument will allow callers to set the default
project branch on repo creation. It takes a list, all branches will be
created with the first being repo HEAD.
Change-Id: Iae5a71662740678e663bcd73d6ac660559db5d9a
Newer versions of flake8 identify these valid violations.
N802 added as skip because the entire library uses camelcase.
Change-Id: Ia687b05bb8d0590eb30a970a710a2639548dbc60
- updates tox.ini, also fixing a typo
- enables new jobs, which would at least test ability to install
package under these versions.
- updates Trove metadata
- replace fake sole-survivor unittest with a bit more practical one
Change-Id: Iae224a19850489ba3563ad5a40d358002dacdb97
We use filter to filter out entries when listing items like groups. This
returns a list in python2 but an iterable in python3. Return a
consistent list via forced coersion.
Change-Id: Iad84f6f383fb85363f3ef51c4bd1da05b8069e43
We want to call addEvent on the 'gerrit' arg passed to GerritWatcher.
For that to work it needs to be of type Gerrit not GerritConnection.
Update the location of username, port, etc data to the connection
details in the gerrit object.
Change-Id: Ic739ddc970f6761f5587ab8fcba3e619a98a4379
We get back bytestrings from paramiko when it talks to gerrit. Make this
a bit more user friendly for python3 and decode these bytestrings into
utf8 unicode.
Change-Id: I1866de53d0978f805faef0933ef37e68454ff5f3
Allow querying to check if a single group entry exists, which when
combined with 'verbose=True' will return the UUID for a single group.
Change-Id: I851ab29999c0d059c9cb71bd38a821c035ae98f7
Move connection related code to a common object to allow reuse of the
connection setup code. This helps avoiding unnecessary recreation of
the connection where it is being used multiple times within the same
process for multiple calls.
Change-Id: Idf318ce5c36100e550182e773ce55da69fe35063
Newer paramiko leaks connections if they are not explicitly closed. Add
a finally handler to always close the ssh connections when we are done
with it to avoid leaking these connections.
Change-Id: Ia2e53998d362683a42bda074d82e3a3a75f380b4
Gerrit < 2.12 used a --name argument on create-project. Newer Gerrit
simply takes the project name as an arg. Check the Gerrit version before
constructing the create-project command.
Change-Id: I59ca051627d54a11ef6524cce9b5a4414fd2193d
The create-project '--name' option was removed[1] in Gerrit 2.12.
Update gerritlib to match the command for Gerrit-2.12+. This is also
compatible with Gerrit 2.11
[1] https://gerrit-review.googlesource.com/#/c/69738/
Change-Id: Ie70d938501cbf88dbbb0e9ab22abcc921f89ccdc
Gerrit supports creating projects that contain spaces in it.
Quote the project name otherwise the command will fail when user
attempts to create a project with spaces in it.
Change-Id: Ie1db92812355b4d8f7603c3b4b8d20434ca54bb3
As of the tox 2.5.0 release, failure to specify a default commands
key in the fallback testenv section of tox.ini instantly fails with
"ERROR: Commands not specified. Please update relevant section of
.../tox.ini".
Copy the testenv.commands entry from the openstack/cookiecutter
repo's template. While at it, copy the boilerplate placeholder test
from the cookiecutter templates so that jobs don't freak out when
they discover (and then run) no tests.
Change-Id: Ifb8fcfbb6d76edd8c7dcf814a705ee7eff3a9819
This change does the following:
Update docs with more info
Add an example usage of this library
Add pbr versioning to docs
Updates the requirements
Rarrange the docs to look better on pypi
Lots of the elements to do above were borrowed from
python-jenkins and jenkins-job-builder projects.
Change-Id: Idc7dfc88cc26e1147b027fd55d41229c4bf3910f
Added ability to view extended information about the groups to obtain information about the uuid.
Function listGroups will be used in jeepyb (in file manage-project.py) for checking
and creating groups in gerrit database if groups does not exist.
Change-Id: Id11e358141d3802026bc7e531146e2d84546463d
Enabled functionality into gerritlib for setting descriptions
when creating a project, or have the ability to update
existing projects to update their descriptions.
This will allow jeepyb to create projects into Gerrit
having proper descriptions.
Change-Id: Id7fdef1599e8632edbdd8af5255207c18c9da7e0
Closes-Bug: #1349372
When creating a new project, if you pass the --empty-commit
flag, a sha is created for the master branch allowing for
cloning and other subsequent actions on the repo. If the project
has no commits and is created without the --empty-commit flag,
the repo is created with no sha for the master branch creating
problems with any subsequent actions on the repo.
Change-Id: Ic233057c2503b7fd9fc234d97d71431520ea70b8
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
On gerrit 2.4.x and gerrit 2.8 the list returned by the listGroups and listProjects
methods always contains one extra item at the end of the list for example listGroups
returns something like.. ['Administrators', 'Anonymous Users', 'Non-Interactive Users',
'Project Owners','Registered Users', '']
This change removes the last item from the returned list.
Change-Id: I2af52a35ef5bc7fd300b12911fce18faab474222
* gerritlib/gerrit.py(Gerrit.createGroup): Quote the group name in
the API call so that Gerrit won't get confused by spaces.
Change-Id: Iad7110bedc2b5b4090313fd70679f0552292a807
Instead of just maintaining a simple boolean that denotes
whether the thread is connected or not, expose a more rich
set of state transitions that can be used by external users
to know exactly the state the thread is currently in.
This new list is:
* IDLE (not initialized/started running)
* DISCONNECTED (not connected to gerrit)
* CONNECTING (attempting to connect)
* CONNECTED (connected to gerrit)
* CONSUMING (consuming events from gerrit)
* DEAD (thread has exited its run method)
The state transitions are the following:
IDLE -> DISCONNECTED
DISCONNECTED -> CONNECTING
CONNECTING -> CONNECTED
CONNECTED -> CONSUMING
CONSUMING -> DISCONNECTED (on consuming failure)
CONNECTING -> DEAD (if no more retries)
Change-Id: Ib4ecef4f093b6d6925bc4b553020e15111248617
In order to allow the GerritWatcher new features for connection
limits and retry limits to be used we need to have a way to
pass those parameters to the watcher when it is constructed.
Change-Id: I199e515e7105b267acbff55a74e03cb117752bab
Add a connect() function that connects
to the ssh server, if this fails it
does a retry algorithm until that fails
and then the thread dies.
If that works, consume from the given client
and if that fails, allow for retrying using
a new client (after a given consume_retry_delay
delay).
To maintain previous behavior the default of
attempting to connect forever is provided when the
number of connection_attempts is <= 0.
Change-Id: I1a2cb764c7cef04b8137a7e4b05d9a4cc45498b0
If the GerritWatcher thread is not set as daemon, the program won't
exit when the main thread exits. This is usually undesirable.
As part of making the thread be a daemon, I've moved the ownership of
threading logic to the gerrit startWatching method, decoupling
GerritWatcher's logic from the implementation detail of being a thread
(vs a co-process etc).
Change-Id: Ib28d5bfec47d2c4c88b99e07dec50ee4dd0104bf
We have all the parameters as public attributes, and never want them
to be different so splitting them out is undesirable.
Change-Id: Ie2826af31100fbc287813e2968a126ff2af50f1f
* gerritlib/gerrit.py: Add listGroups() method that will run `gerrit
ls-groups` and return the result as a python list.
Change-Id: I2cb6b7b6a23f3efdb81f90b492c07075c4606c38