From: Thanh Ha Date: Fri, 24 Aug 2018 15:38:27 +0000 (-0400) Subject: Make ldap module optional X-Git-Tag: v0.16.1^0 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F84%2F12384%2F3;p=releng%2Flftools.git Make ldap module optional Install via 'pip install lftools[ldap]'. Change-Id: Ie2206b43b094e1576936ba934268dc0b68fc5a40 Signed-off-by: Thanh Ha --- diff --git a/lftools/cli/__init__.py b/lftools/cli/__init__.py index 1be0debf..21df0bad 100644 --- a/lftools/cli/__init__.py +++ b/lftools/cli/__init__.py @@ -20,7 +20,6 @@ from lftools.cli.dco import dco from lftools.cli.deploy import deploy from lftools.cli.infofile import infofile from lftools.cli.jenkins import jenkins_cli -from lftools.cli.ldap_cli import ldap_cli from lftools.cli.license import license from lftools.cli.nexus import nexus from lftools.cli.sign import sign @@ -51,7 +50,14 @@ cli.add_command(license) cli.add_command(nexus) cli.add_command(sign) cli.add_command(version) -cli.add_command(ldap_cli, name='ldap') + +try: + from lftools.cli.ldap_cli import ldap_cli + cli.add_command(ldap_cli, name='ldap') +except ImportError: + from lftools.cli.no_cmd import no_ldap as ldap_cli + cli.add_command(ldap_cli, name='ldap') + try: from lftools.openstack.cmd import openstack diff --git a/lftools/cli/ldap_cli.py b/lftools/cli/ldap_cli.py index b4bdf770..71ecb10d 100644 --- a/lftools/cli/ldap_cli.py +++ b/lftools/cli/ldap_cli.py @@ -21,6 +21,7 @@ import subprocess import sys import click + import ldap diff --git a/lftools/cli/no_cmd.py b/lftools/cli/no_cmd.py new file mode 100644 index 00000000..6c45dae7 --- /dev/null +++ b/lftools/cli/no_cmd.py @@ -0,0 +1,26 @@ +# -*- code: utf-8 -*- +# SPDX-License-Identifier: EPL-1.0 +############################################################################## +# Copyright (c) 2018 The Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################## +"""CLI configuration for ldap command.""" + +__author__ = 'Thanh Ha' + + +import click + + +@click.group() +@click.pass_context +def no_ldap(ctx): + """(lftools[ldap]) Provides an ldap interface. + + To activate this interface run `pip install lftools[ldap]`. + """ + pass diff --git a/releasenotes/notes/ldap-b50f699fc066890f.yaml b/releasenotes/notes/ldap-b50f699fc066890f.yaml new file mode 100644 index 00000000..6277055e --- /dev/null +++ b/releasenotes/notes/ldap-b50f699fc066890f.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + The v0.16.0 pulled in a new ldap module which breaks if the ldap devel + libraries are not available on the system trying to use it. This hotfix + makes the ldap module optional. diff --git a/requirements.txt b/requirements.txt index bba62593..1f76aecd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ click -python-ldap pyyaml requests~=2.18.0 ruamel.yaml diff --git a/setup.cfg b/setup.cfg index 2cafa329..1d1ed796 100644 --- a/setup.cfg +++ b/setup.cfg @@ -23,6 +23,8 @@ classifier = Programming Language :: Python :: 3.7 [extras] +ldap = + python-ldap~=3.1.0 openstack = shade~=1.27.1