Comment 2 for bug 1223934

Revision history for this message
kesten broughton (dathomir) wrote :

The trace is fairly helpful.
The error comes from _add_details on the setattr line.
Keypairs inherits from base.Resource in base.py.
Note the difference and the comment (setattr is surrounded with a try catch in base.Resource.
If you wrap the setattr in KeyPair's _add_details, the error goes away.

To fix:
locate v1_1/keypairs.py
for me they were located here:
/opt/stack/python-novaclient/novaclient/v1_1/keypairs.py
/home/stack/savanna-venv/lib/python2.7/site-packages/novaclient/v1_1/keypairs.py

I also deleted the .pyc versions of these files, though that shouldn't be necessary.

Test it first on
nova keypair-list
if that succeeds then stop the savana process and restart (from the parent directory to savanna-venv) with
savanna-venv/bin/python savanna-venv/bin/savanna-api --config-file savanna-venv/etc/savanna.conf

# KeyPair in keypairs.py
    def _add_details(self, info):
        dico = 'keypair' in info and \
            info['keypair'] or info
        for (k, v) in dico.items(): ## wrap this for loop in a try/catch like in base.Resource
            setattr(self, k, v)

# base.Resource in base.py
    def _add_details(self, info):
        for (k, v) in six.iteritems(info):
            try:
                setattr(self, k, v)
                self._info[k] = v
            except AttributeError:
                # In this case we already defined the attribute on the class
                pass