batrick / ceph-linode

Launch Ceph using the Linode VPS provider
GNU General Public License v3.0
13 stars 10 forks source link

can't find Api constructor - has linode API changed? #2

Closed bengland2 closed 6 years ago

bengland2 commented 6 years ago

I did as instructed in README and when I ran it, it gave me the error shown here. The python API for linode appears to have changed? Current Linode API documentation for REST API is here.

batrick commented 6 years ago

Are you sure you installed the linode-python pip module? I just tried out the steps in the README on a fresh install and had no issues.

bengland2 commented 6 years ago

BTW I'm running Fedora 26 and python 2.7. I think maybe I have a linode API version problem. I retried this way to isolate problem after following README.md instructions:

virtualenv-2 linode-env && source linode-env/bin/activate && pip install linode-python
New python executable in /home/bengland/ceph/ceph-linode/linode-env/bin/python2
Not overwriting existing python script /home/bengland/ceph/ceph-linode/linode-env/bin/python (you must use /home/bengland/ceph/ceph-linode/linode-env/bin/python2)
Installing setuptools, pip, wheel...done.
Requirement already satisfied: linode-python in ./linode-env/lib/python2.7/site-packages

then defined:

export LINODE_API_KEY=`cat ~/ceph/linode-api.key

then reproduced the exception from your linode-launch.py program using:

(linode-env) [bengland@bene-laptop ceph-linode]$ python
Python 2.7.13 (default, Sep  5 2017, 08:53:59) 
[GCC 7.1.1 20170622 (Red Hat 7.1.1-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import linode
>>> from linode import api as linapi
>>> import os
>>> k = os.getenv('LINODE_API_KEY')
>>> client = linapi.Api(key=k)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'Api'

This Api class is not mentioned in linode documentation that I found. Nor is it present in the code. But it is mentioned in unit test such as this one:

# python linode-env/lib/python2.7/site-packages/linode/tests.py
EE
======================================================================
ERROR: testAvailLinodeplans (__main__.ApiTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "linode-env/lib/python2.7/site-packages/linode/tests.py", line 9, in setUp
    self.linode = api.Api(os.environ['LINODE_API_KEY'])
AttributeError: 'module' object has no attribute 'Api'

======================================================================
ERROR: testEcho (__main__.ApiTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "linode-env/lib/python2.7/site-packages/linode/tests.py", line 9, in setUp
    self.linode = api.Api(os.environ['LINODE_API_KEY'])
AttributeError: 'module' object has no attribute 'Api'

----------------------------------------------------------------------
Ran 2 tests in 0.000s

FAILED (errors=2)

I see linode_api-4.1.3b1.dist-info in linode-env/lib/python2.7/site-packages, am going to try earlier API shown in

$ sudo pip search linode
...
linode_api3 (0.1.5)
...
batrick commented 6 years ago

This Api class is not mentioned in linode documentation that I found. Nor is it present in the code. But it is mentioned in unit test such as this one:

You're looking at the wrong Python library. This is the correct one: https://github.com/tjfontaine/linode-python

Here's what I get:

pdonnell@icewind ~/ceph-linode$ virtualenv2 venv
New python executable in /home/pdonnell/scm/ceph-linode/venv/bin/python2
Also creating executable in /home/pdonnell/scm/ceph-linode/venv/bin/python
Installing setuptools, pip, wheel...done.
pdonnell@icewind ~/ceph-linode$ source venv/bin/activate
(venv) pdonnell@icewind ~/ceph-linode$ pip install linode-python
Collecting linode-python
Installing collected packages: linode-python
Successfully installed linode-python-1.1.1
(venv) pdonnell@icewind ~/ceph-linode$ python2
Python 2.7.13 (default, Jul 21 2017, 03:24:34)
[GCC 7.1.1 20170630] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import linode
>>> from linode import api as linapi
/home/pdonnell/scm/ceph-linode/venv/lib/python2.7/site-packages/linode/api.py:83: RuntimeWarning: using urllib instead of pycurl, urllib does not verify SSL remote certificates, there is a risk of compromised communication
  warnings.warn(ssl_message, RuntimeWarning)
>>> linapi.Api
<class linode.api.Api at 0x7f4e567d27a0>

What does help(linode.api) say?

batrick commented 6 years ago

@fullerdj, are you using Fedora? Did you see this problem?

fullerdj commented 6 years ago

No, I’m using CentOS (since shaman builds for it). I used ceph-linode successfully today.

bengland2 commented 6 years ago

Patrick, see this pastebin, I think it is a version problem since I looked at pointer that you gave me for correct python library and it was 0.3 version, Linode has replaced with 0.4 since then, I think - see the top of the preceding link. You might clarify which version of the library to use in README.

bengland2 commented 6 years ago

The library you pointed me to seems to work fine, thanks!