This should have gerritlib log the commands it is running in the logs,
which helps with verification.
Change-Id: Iad3c710d73a95d152689d8a60a7ef4051129b0f9
The previous change assumed that all projects would have their acl file
paths updated via ansible's lineinfile module. But lineinfile only
updates the last match. Since we've got two config lines we want to
match and update we run the lineinfile task twice which should end up
updating both of them.
Change-Id: I714281d86569f248f4ae3d909b019f060fe6c520
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
Avoids conflicts between unit testing and linter and avoids
installing unneeded dependencies on both of them.
Change-Id: Id384a998bea298612ec65eaa329f85a38afee3f6
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
Now that we're running manage-projects in a python3 container,
we should switch our integration tests to use python3.
Depends-On: https://review.opendev.org/715527
Change-Id: I33a6daf92906d9087c4a31f11966e5037445cd68
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
This adds integration testing to gerritlib with jeepyb and gerrit.
Depends-On: https://review.opendev.org/704660
Change-Id: I1815e63693656d52c10a9cb9bf60f999e036dfed
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
Old paramiko uses pycrypto which is out of date and insecure. Switch to
new paramiko and cryptography instead.
Change-Id: I651244d549d10a848643d1e3b96438833a5954bd
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
This is a mechanically generated change to replace openstack.org
git:// URLs with https:// equivalents.
This is in aid of a planned future move of the git hosting
infrastructure to a self-hosted instance of gitea (https://gitea.io),
which does not support the git wire protocol at this stage.
This update should result in no functional change.
For more information see the thread at
http://lists.openstack.org/pipermail/openstack-discuss/2019-March/003825.html
Change-Id: I194eaf19074655822776b2e533519607622738c8
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
Until we have a good migration plan for paramika, lets cap at <2.0.0.
Otherwise we need to install libffi-dev and other dependencies for the
version bump.
Change-Id: Iad29f93814c798fc2c4204e08e940011ad1428dc
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
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
Based on cookiecutter and slightly tweaked afterward.
* conf.py has autoclass_content = 'both' to generate the __init__
documentation.
* bumped doc copyright to 2015.
* adds in tox environement 'docs' as a convenience
Change-Id: I69bb4179be343ab7c8a44f6fb80d5a428fe30e17
Replace URLs for workflow documentation to appropriate parts of the
OpenStack Project Infrastructure Manual.
Change-Id: I25f5dbee234b6d6121beb9ffcf97809dd1a41bb1