调用open stack API时Unauthorized的错误

在调用open stack API时出现Unauthorized的错误,但是查看配置都没有发现问题

novaclient.exceptions.Unauthorized: This server could not verify that you are authorized to access the document you requested. Either you supplied the wrong credentials (e.g., bad password), or your browser does not understand how to supply the credentials required.<br /><br />

glanceclient.exc.HTTPUnauthorized: HTTP 401 Unauthorized: This server could not verify that you are authorized to access the document you requested. Either you supplied the wrong credentials (e.g., bad password), or your browser does not understand how to supply the credentials required.

debug:
Wireshark抓包发现http报文的目的ip不是controller的ip 172.171.19.190,是一个网段的其他ip号 172.171.29.200;
arp -a发现有这个未知的ip号,arp -d之后,运行调用api的函数再arp -a又会出现;
ping controller -4发现显示ping的ip刚好是抓到的包里面的目的ip,于是想到可能是dns解析错误;
解决
在host文件( C:\Windows\System32\drivers\etc\hosts)中添加controller的域名解析

C:\Windows\system32>arp -d *

C:\Windows\system32>
C:\Windows\system32>arp -a

接口: 2.0.1.45 --- 0x6
  Internet 地址         物理地址              类型
  224.0.0.22            01-00-5e-00-00-16     静态

接口: 172.171.17.10 --- 0x9
  Internet 地址         物理地址              类型
  172.171.16.1          94-29-2f-30-5a-01     动态
  224.0.0.22            01-00-5e-00-00-16     静态

C:\Windows\system32>arp -a

接口: 2.0.1.45 --- 0x6
  Internet 地址         物理地址              类型
  2.0.1.44              12-34-56-78-9a-bc     动态
  2.0.1.255             ff-ff-ff-ff-ff-ff     静态
  224.0.0.22            01-00-5e-00-00-16     静态
  224.0.0.251           01-00-5e-00-00-fb     静态
  224.0.0.252           01-00-5e-00-00-fc     静态

接口: 172.171.17.10 --- 0x9
  Internet 地址         物理地址              类型
  172.171.16.1          94-29-2f-30-5a-01     动态
  172.171.29.200        0c-29-ef-0a-3d-8e     动态
  172.171.31.255        ff-ff-ff-ff-ff-ff     静态
  224.0.0.22            01-00-5e-00-00-16     静态
  224.0.0.251           01-00-5e-00-00-fb     静态
  224.0.0.252           01-00-5e-00-00-fc     静态
C:\Windows\system32>
C:\Windows\system32>ping controller -4

正在 Ping controller.local [172.171.29.200] 具有 32 字节的数据:
来自 172.171.29.200 的回复: 字节=32 时间<1ms TTL=64
来自 172.171.29.200 的回复: 字节=32 时间<1ms TTL=64
来自 172.171.29.200 的回复: 字节=32 时间<1ms TTL=64
来自 172.171.29.200 的回复: 字节=32 时间<1ms TTL=64

172.171.29.200 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 0ms,最长 = 0ms,平均 = 0ms

C:\Windows\system32>
C:\Windows\system32>ipconfig /flushdns

Windows IP 配置

已成功刷新 DNS 解析缓存。

C:\Windows\system32>
C:\Windows\system32>
C:\Windows\system32>
C:\Windows\system32>ping controller -4

正在 Ping controller [172.171.19.190] 具有 32 字节的数据:
来自 172.171.19.190 的回复: 字节=32 时间=3ms TTL=62
来自 172.171.19.190 的回复: 字节=32 时间=3ms TTL=62
来自 172.171.19.190 的回复: 字节=32 时间=3ms TTL=62
来自 172.171.19.190 的回复: 字节=32 时间=2ms TTL=62

172.171.19.190 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 2ms,最长 = 3ms,平均 = 2ms

C:\Windows\system32>
C:\Windows\system32>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。