【问题标题】:Allocating EIP using Alibaba python SDK doesn't work使用阿里巴巴python SDK分配EIP不起作用
【发布时间】:2019-02-28 08:52:35
【问题描述】:

我正在使用 python SDK 来使用阿里巴巴 ECS 。我无法使用它创建弹性 ip (EIP)。我使用了以下代码。

from aliyunsdkcore.client import AcsClient
from aliyunsdkecs.request.v20140526 import AllocateEipAddressRequest

AccessKeyId = '*****************'
AccessKeySecret = '*******************'
DefaultRegion = 'us-east-1'

client = AcsClient(AccessKeyId, AccessKeySecret, DefaultRegion)
request_eip = AllocateEipAddressRequest.AllocateEipAddressRequest()
response = client.do_action_with_exception(request_eip)

它会引发以下错误。

aliyunsdkcore.acs_exception.exceptions.ServerException: HTTP Status: 500 Error:InternalError The request processing has failed due to some unknown error, exception or failure. RequestID: XXXXXXXXXXXXXXXXXXXXXXXXXXX

我在这里缺少什么? 请帮忙!

【问题讨论】:

  • 你能再做一个动作吗?没事吧?
  • 是的,ECS 操作的所有其他操作对我来说都可以正常工作。我只有创建 EIP 的问题。

标签: alibaba-cloud alibaba-cloud-ecs


【解决方案1】:

这是阿里巴巴官方支持团队的回复,解决了我的问题。

尊敬的客户

很遗憾地通知您,此案例与 ECS API 中的一个已知问题有关。我们的后端团队将在下一版本的 ECS VPC API 中解决这个问题。

同时,请在您的请求中添加可选参数“InternetChargeType”:“PayByBandwidth”作为解决方法。

#Example Code:

def main():
    client = AcsClient(
        "LTxxxxxxxxxxxxH",
        "RxxxxxxxxxxxxxxT",
        "ur region")
    request_eip = AllocateEipAddressRequest.AllocateEipAddressRequest()
    request_eip.set_InternetChargeType('PayByTraffic')
    response = client.do_action_with_exception(request_eip)
    print(response)

谢谢

【讨论】: