2

我正在尝试使用 boto 创建自动缩放的启动配置,但我不知道如何定义 block_device_mappings。

代码快照如下:

dev_sdf = boto.ec2.blockdevicemapping.EBSBlockDeviceType(snapshot_id = self.sna_data.id)
bdm = boto.ec2.blockdevicemapping.BlockDeviceMapping()
bdm['/dev/sdf'] = dev_sdf

lc = launchconfig.LaunchConfiguration(connection = self.as_conn,
                                      name = lc_name,
                                      image_id = self.ami.id,
                                      instance_type = self.instance_type,
                                      key_name = AWS_KEY_NAME,
                                      security_groups = self.security_groups,
                                      spot_price = self.price,
                                      block_device_mappings = [bdm])
self.as_conn.create_launch_configuration(lc)

但我得到了:

boto.exception.BotoServerError: BotoServerError: 400 Bad Request
<ErrorResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
  <Error>
    <Type>Sender</Type>
    <Code>ValidationError</Code>
    <Message>1 validation error detected: Value null at 'blockDeviceMappings.1.member.deviceName' failed to satisfy constraint: Member must not be null</Message>
  </Error>
  <RequestId>7289473c-7bc1-11e2-a07c-93de372a2cc0</RequestId>
</ErrorResponse>

我应该如何定义 block_device_mappings?

4

1 回答 1

1

我不认为加载映射的代码可以工作。

我已经针对应该正确拉动设备映射的 boto 代码创建了拉取请求:

https://github.com/pasc/boto/tree/bdm_for_autoscaling_groups

于 2013-02-26T12:48:46.687 回答