2017-04-24 119 views
2

我写了一些python代码与Openstack实例进行交互;使用shade库。连接到OpenStack失败

呼叫

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

工作在我的本地Ubuntu安装罚款;但在我们的“后端”服务器上运行失败(运行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'

该系统的管理员告诉我在那里没有启用IPv6;也许这就解释了失败。我做了一些研究,但没有找到任何防止失败的方法。

任何的想法是受欢迎的。

更新:我编辑了我的clouds.yml;它看起来像这样:

# 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 

我也试过export OS_FORCE_IPV4=True - 但错误信息仍然存在。

回答

2

如果你通过OpenStack os-client-config documentation,他们已经提到了有关IPV6相关问题。

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.

因此,使用这些boolean配置您可以强制适当的网络协议。下面的添加行到您的clouds.yaml文件

client: 
    force_ipv4: true 

将迫使IPV4,并希望它能够解决您的问题。

由OP编辑:不幸的是,上面没有帮助;通过返工shade-1.20.0-py3.5.egg/shade/_utils.py固定它:我改变了return语句

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

一个简单

return False 

之类的东西是工作。当然,这只是一个解决方法;但也提交了一份错误报告。

+0

我无法复制您的问题,因此只是添加了一个可能的解决方案。 – Rahul

+0

谢谢@GhostCat – Rahul