如何从boto获得有用的诊断?

Roy*_*ith 9 amazon-ec2 boto

如何从boto中获得有用的诊断信息?我似乎得到的只是令人愤怒的无用的"400 Bad Request".我认识到boto只是传递底层API提供的内容,但肯定有一些方法可以获得比"Bad Request"更有用的东西.

Traceback (most recent call last):
  File "./mongo_pulldown.py", line 153, in <module>
    main()
  File "./mongo_pulldown.py", line 24, in main
    print "snap = %r" % snap
  File "./mongo_pulldown.py", line 149, in __exit__
    self.connection.delete_volume(self.volume.id)
  File "/home/roy/deploy/current/python/local/lib/python2.7/site-packages/boto/ec2/connection.py", line 1507, in delete_volume
    return self.get_status('DeleteVolume', params, verb='POST')
  File "/home/roy/deploy/current/python/local/lib/python2.7/site-packages/boto/connection.py", line 985, in get_status
    raise self.ResponseError(response.status, response.reason, body)
boto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request
Run Code Online (Sandbox Code Playgroud)

j0n*_*nes 8

您可以将boto.cfg文件配置为更详细:

[Boto]
debug = 2
Run Code Online (Sandbox Code Playgroud)

debug:控制将由boto库打印的调试消息的级别.定义了以下值:

0 - no debug messages are printed
1 - basic debug messages from boto are printed
2 - all boto debugging messages plus request/response messages from httplib
Run Code Online (Sandbox Code Playgroud)


小智 6

将调试设置放在配置文件中没有太多运气,但是对ec2.connect_to_region()的调用采用了调试参数,其值与j0nes的答案相同.

ec2 = boto.ec2.connect_to_region("eu-west-1", debug=2)
Run Code Online (Sandbox Code Playgroud)

连接对象发送/接收的所有内容都将转储到stdout.