我已经编写了一些 python 代码来与 Openstack 实例进行交互;使用 shade图书馆。
电话
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 - 但错误消息仍然存在。
请您参考如下方法:
如果您通过 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 配置,您可以强制使用适当的网络协议(protocol)。将以下行添加到您的 clouds.yaml 文件
client:
force_ipv4: true
将强制执行 IPV4,希望它能解决您的问题。
由 OP 编辑:不幸的是,以上内容没有帮助;通过修改 shade-1.20.0-py3.5.egg/shade/_utils.py 修复了它:我更改了返回语句
return netifaces.AF_INET6 in netifaces.gateways()['default']`
一个简单的
return False
一切正常。当然,这只是一种解决方法;但也提交了错误报告。
