This is an automated email from the ASF dual-hosted git repository. tomaz pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit 222749bab9c782974aff0ab68f549b8dc0ca44ae Author: Tomaz Muraus <[email protected]> AuthorDate: Wed Dec 18 23:18:29 2019 +0100 Make OpenSSL import lazy since only two methods depend on it. --- libcloud/loadbalancer/drivers/nttcis.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libcloud/loadbalancer/drivers/nttcis.py b/libcloud/loadbalancer/drivers/nttcis.py index 5c24ce6..b0a0bf9 100644 --- a/libcloud/loadbalancer/drivers/nttcis.py +++ b/libcloud/loadbalancer/drivers/nttcis.py @@ -13,13 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -try: - import OpenSSL - OpenSSL -except ImportError: - raise ImportError('Missing "OpenSSL" dependency. You can install it ' - 'using pip - pip install pyopenssl') -from OpenSSL import crypto from libcloud.utils.py3 import ET from libcloud.common.nttcis import NttCisConnection from libcloud.common.nttcis import NttCisPool @@ -783,6 +776,11 @@ class NttCisLBDriver(Driver): :type `description: `str`` :return: ``bool`` """ + try: + import OpenSSL + except ImportError: + raise ImportError('Missing "OpenSSL" dependency. You can install it ' + 'using pip - pip install pyopenssl') with open(crt_file) as fp: c = OpenSSL.crypto.load_certificate( @@ -846,6 +844,13 @@ class NttCisLBDriver(Driver): :type description: ``str`` :return: ``bool`` """ + try: + import OpenSSL + from OpenSSL import crypto + except ImportError: + raise ImportError('Missing "OpenSSL" dependency. You can install it ' + 'using pip - pip install pyopenssl') + c = crypto.load_certificate( crypto.FILETYPE_PEM, open(chain_crt_file).read()) cert = OpenSSL.crypto.dump_certificate(
