pythonopenstackopenstack-shade

Connect to openstack is failing


I have written a bit of python code to interact with an Openstack instance; using the shade library.

The call

myinstance = shade.openstack_cloud(cloud='mycloud', **auth_data)

works fine on my local Ubuntu installation; but fails on our "backend" servers (running RHEL 7.2).

File "mystuff/core.py", line 248, in _create_connection myinstance = shade.openstack_cloud(cloud='mycloud', **auth_data)

File "/usr/local/lib/python3.5/site-packages/shade-1.20.0-py3.5.egg/shade/init.py", line 106, in openstack_cloud return OpenStackCloud(cloud_config=cloud_config, strict=strict)

File "/usr/local/lib/python3.5/site-packages/shade-1.20.0-py3.5.egg/shade/openstackcloud.py", line 312, in init self._local_ipv6 = _utils.localhost_supports_ipv6()

File "/usr/local/lib/python3.5/site-packages/shade-1.20.0-py3.5.egg/shade/_utils.py", line 254, in localhost_supports_ipv6 return netifaces.AF_INET6 in netifaces.gateways()['default']

AttributeError: module 'netifaces' has no attribute 'AF_INET6'

The admin for that system tells me that IPv6 is not enabled there; maybe that explains the fail. I did some research, but couldn't find anything to prevent the failure.

Any thoughts are welcome.

Update: I edited my clouds.yml; and it looks like this:

# openstack/shade config file 
# required to connect provisioning using the shade module
client:
    force_ipv4: true
clouds:
    mycloud:
        auth:
        user_domain_name: xxx
        auth_url: 'someurl'
    region_name: RegionOne

I also tried export OS_FORCE_IPV4=True - but the error message is still there.


Solution

  • If you go through the OpenStack os-client-config documentation, there they have mentioned about IPV6 related issue.

    IPv6 is the future, and you should always use it if your cloud supports it and if your local network supports it. Both of those are easily detectable and all friendly software should do the right thing. However, sometimes you might exist in a location where you have an IPv6 stack, but something evil has caused it to not actually function. In that case, there is a config option you can set to unbreak you force_ipv4, or OS_FORCE_IPV4 boolean environment variable.

    So, using these boolean config you can force appropriate network protocol. Adding below lines to your clouds.yaml file

     client:
       force_ipv4: true
    

    will force IPV4 and hope it will resolve your issue.

    Edit by OP: unfortunately the above doesn't help; fixed it by reworking shade-1.20.0-py3.5.egg/shade/_utils.py: I changed the return statement

    return netifaces.AF_INET6 in netifaces.gateways()['default']` 
    

    to a simple

    return False
    

    And stuff is working. Of course, this is just a workaround; but a bug report was filed as well.