107 Commits

Author SHA1 Message Date
Brian Rosmaita
f34c110fd9 Update documentation
Update various URLs in the docs, add .eggs to .gitignore, and correct
a pep8 problem in gerrit.py

Change-Id: Ie86ff3a7cb6e9c742eac0eab243cc374ead42fb6
2021-01-04 22:19:38 -05:00
Ian Wienand
99136e1e16 integration test: run manage-projects with debug
This should have gerritlib log the commands it is running in the logs,
which helps with verification.

Change-Id: Iad3c710d73a95d152689d8a60a7ef4051129b0f9
0.10.0
2020-12-03 11:34:28 +11:00
Clark Boylan
3ff5407988 Test manage-projects repos harder
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
2020-12-02 15:28:32 -08:00
Clark Boylan
a7f00a4d9b Handle newer Gerrit ls-groups command syntax
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
2020-12-02 14:36:20 -08:00
Zuul
05d2786986 Merge "Avoid crash due to POLLIN event check" 2020-12-02 14:29:33 +00:00
Ian Wienand
194ddff30a Handle empty reads as closed connections
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
2020-11-24 11:58:48 +11:00
Sorin Sbarnea
12e395e8ea Avoid crash due to POLLIN event check
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
2020-11-03 09:27:08 +00:00
Zuul
73005984a9 Merge "Decouple linters from unit testing" 2020-10-01 03:07:04 +00:00
Zuul
a32237cc7d Merge "Fix package metadata" 2020-10-01 03:02:36 +00:00
Sorin Sbarnea
b317b5737c Fix package metadata
Updates outdated urls, mailing lists and team names in metadata.

Change-Id: I69a88c3bdeb5b5b363d606648b1ae034912fc4c3
2020-09-28 16:33:54 +00:00
Sorin Sbarnea
ac82273984 Allow custom retries on gerrit connection
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
2020-09-28 16:50:00 +01:00
Sorin Sbarnea
8ceeaa5a20 Decouple linters from unit testing
Avoids conflicts between unit testing and linter and avoids
installing unneeded dependencies on both of them.

Change-Id: Id384a998bea298612ec65eaa329f85a38afee3f6
2020-09-28 16:45:59 +01:00
Arun S A G
40858f3678 Add support for TCP keep alive in gerritlib
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
2020-09-09 17:45:39 -07:00
Clark Boylan
6058d994b8 Add branches arg to createProject
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
0.9.0
2020-07-15 11:11:44 -07:00
Sorin Sbarnea
95e17ddf05 Fixed linting issues
Newer versions of flake8 identify these valid violations.
N802 added as skip because the entire library uses camelcase.

Change-Id: Ia687b05bb8d0590eb30a970a710a2639548dbc60
2020-05-21 17:12:40 +01:00
Sorin Sbarnea
2f666c7b35 Replace testrepository with stestr
Replace outdated testrepository with its newer sibling, which
is maintained.

Change-Id: I9755b82d8a2a82f146e71fdc0f32e3f6002e804d
2020-05-20 20:07:15 +01:00
Sorin Sbarnea
a0a5f260ea Enable py36-py38 testing
- 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
2020-05-20 19:38:05 +01:00
Sorin Sbarnea
c49a8e0e5f Added missing retry_delay instance variable
Found exception at line 179, where self.retry_delay was references
without being assigned.

Change-Id: I6d00fe9478ed3467120e0441bed3c32f68e20bca
2020-05-20 18:13:21 +01:00
vass
ad26169a4d Use ensure-* roles
The install-* roles in zuul-jobs have been renamed to ensure-*, follow
the rename.

Change-Id: Ia5dffd38399142d9f17a1123b3e4a46bdbca7662
2020-04-13 09:36:36 +02:00
Zuul
04537022f9 Merge "Return lists from listing functions" 0.8.4 2020-03-30 17:35:16 +00:00
Monty Taylor
833fce6eba Run gerritlib integration tests with python3
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
2020-03-27 16:22:57 -05:00
Clark Boylan
17380a3e71 Return lists from listing functions
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
2020-03-27 14:18:05 -07:00
Zuul
cfceeb50e0 Merge "Add integration testing with jeepyb and gerrit" 2020-03-22 14:06:04 +00:00
Clark Boylan
fa0a23a751 Pass Gerrit not GerritConnection to GerritWatcher
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
0.8.3
2020-01-28 14:14:20 -08:00
Clark Boylan
2b81068c01 Add integration testing with jeepyb and gerrit
This adds integration testing to gerritlib with jeepyb and gerrit.

Depends-On: https://review.opendev.org/704660
Change-Id: I1815e63693656d52c10a9cb9bf60f999e036dfed
2020-01-28 11:01:01 -08:00
Zuul
d244a41362 Merge "Convert gerrit output to utf8 unicode" 2020-01-28 02:28:47 +00:00
Zuul
0b438471c8 Merge "Use newer paramiko" 0.8.2 2020-01-28 02:00:56 +00:00
Clark Boylan
945d2088a7 Convert gerrit output to utf8 unicode
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
2020-01-27 16:13:13 -08:00
Clark Boylan
c234e11b51 Use newer paramiko
Old paramiko uses pycrypto which is out of date and insecure. Switch to
new paramiko and cryptography instead.

Change-Id: I651244d549d10a848643d1e3b96438833a5954bd
2020-01-27 16:13:11 -08:00
Darragh Bailey
a731676fd1 Support querying for single group info
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
2020-01-23 12:11:34 +00:00
Darragh Bailey
500c8d2cc9 Reuse same paramiko connection recreating on errors
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
2020-01-23 12:01:52 +00:00
OpenDev Sysadmins
609deaf9a5 OpenDev Migration Patch
This commit was bulk generated and pushed by the OpenDev sysadmins
as a part of the Git hosting and code review systems migration
detailed in these mailing list posts:

http://lists.openstack.org/pipermail/openstack-discuss/2019-March/003603.html
http://lists.openstack.org/pipermail/openstack-discuss/2019-April/004920.html

Attempts have been made to correct repository namespaces and
hostnames based on simple pattern matching, but it's possible some
were updated incorrectly or missed entirely. Please reach out to us
via the contact information listed at https://opendev.org/ with any
questions you may have.
2019-04-19 19:26:01 +00:00
Ian Wienand
1d63855d0d Replace openstack.org git:// URLs with https://
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
2019-03-24 20:33:40 +00:00
Zuul
f7d1832b45 Merge "Updated list of Python versions in tox" 2018-06-28 17:01:33 +00:00
Clark Boylan
2de58d560f Close ssh connections when done with them
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
0.8.1
2018-05-03 13:39:57 -07:00
Sorin Sbarnea
ffbc080f1a Updated list of Python versions in tox
Change-Id: I40118820d7eb0956dc012556aa1d5767f40d652e
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
2018-01-27 14:50:51 +00:00
Clark Boylan
01a634014e Add group membership management functions
Add functions to list group members and add and remove users from
groups.

Change-Id: Id5d8915f2c0bf6f6057b414785b8ec1b18e810f2
0.8.0
2017-09-22 10:24:53 -07:00
Clark Boylan
eb6588734c Handle different gerrit versions with create-project
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
0.7.0
2017-09-19 16:25:39 -07:00
Khai Do
d9478fcc08 Remove pyflakes environment
There are no test jobs for flake8 so this is not neeeded.

Change-Id: I63c7ae85510a86d0667b96da6526fa0df5aa621a
2017-06-15 13:26:41 +00:00
Sorin Sbarnea
2c8298394f Removed pbr<2.0.0 to resolve depencency conflicts
Change-Id: Ia96cef693d82b42320561df80eb5a571085cda93
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
2017-03-30 21:37:20 +01:00
Khai Do
4527edd4ad Remove deprecated create-project '--name' option
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
2016-12-01 15:05:50 -08:00
Khai Do
33feeb837b Allow creating projects with spaces
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
2016-12-01 15:04:50 -08:00
Jeremy Stanley
fba7102ae4 Specify testenv command for tox>=2.5
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
2016-12-01 20:20:59 +00:00
Paul Belanger
11647ed384
Cap paramiko<2.0.0
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>
0.6.0
2016-05-25 11:03:42 -04:00
Khai Do
cd183a4f43 Stop specifying requirements.txt in tox.ini
As PBR already injects the contents of requirements.txt into
setup_requires, there is no need for tox to explicitly install them.
http://lists.openstack.org/pipermail/openstack-dev/2015-July/069663.html

Change-Id: I5fc4de208e6c2f6926238f6942bf4ca9804748e4
2015-08-10 15:38:34 -07:00
Monty Taylor
24de1df8df Bump pbr and hacking version
Bumping pbr required a bump to hacking otherwise build will fail
with VersionConflict error.

Change-Id: I3d2a031c175dcd25b309bd3cbf15f5ebad0c4744
2015-08-02 14:00:44 -07:00
Khai Do
58ca447785 Update project docs
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
0.5.0
2015-04-20 13:10:34 -07:00
Jenkins
0a3531b432 Merge "Doc generation support" 2015-03-13 02:42:04 +00:00
Antoine Musso
207357ea9e Doc generation support
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
2015-02-11 10:09:59 +01:00
Jeremy Stanley
60269be836 Workflow documentation is now in infra-manual
Replace URLs for workflow documentation to appropriate parts of the
OpenStack Project Infrastructure Manual.

Change-Id: I25f5dbee234b6d6121beb9ffcf97809dd1a41bb1
2014-12-05 11:51:53 -08:00