我正在使用 openstacksdk 上传图像以供浏览。 这里使用的网址是错误的。
node-1:~$ ping -c 1 -t 5 10.1.1.2
PING 10.1.1.2 (10.1.1.2) 56(84) bytes of data.
From 10.255.237.91 icmp_seq=1 Time to live exceeded
--- 10.1.1.2 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
示例代码:
url='http://10.1.1.2:5000/v3'
try:
conn = connection.Connection(
auth_url=url,
username='user',
password='pass',
project_name='admin',
user_domain_name='default',
project_domain_name='default',
region_name='RegionOne',
cert=cert_file_path
)
image = conn.create_image(
name='test_image',
filename='test_image.img,
timeout=20
)
except keystoneauth1.exceptions.connection.ConnectFailure as e:
print('Connect Failure')
except keystoneauth1.exceptions.catalog.EndpointNotFound as e:
print('Endpoint not found')
... some other exceptions
except openstack.exceptions.SDKException as e:
print(f'sdk exception: {str(e)}')
except Exception as e:
print(f'Some other error {str(e)}')
但是,我没有收到任何异常或超时错误。我错过了什么? 注意:使用正确的 IP 地址,我可以上传测试图像以供浏览。