ec2 driver does not support strings for size and image parameters
- 主要语言
- Python
- 星标
- 2.1k
- 派生
- 931
- 平均合并
- 1 天 2 小时
- 30 天内合并 PR
- 4
描述
## Summary
Both the GCP and the Dummy drivers for compute allow passing the imaged id, and size id as a string, and both drivers will do a lookup to find them.
The EC2 driver requires that the image and size be objects that have the name as an id attribute.
## Detailed Information
The commit https://github.com/newcontext-oss/openc2-aws-actuator/commit/f67cbee488236604b65c72a8f5f695fddf9592e9 fixes the issue for that code. GCP works w/ the previous commit.
This is on MacOSX 10.14.6.
```
$python
Python 3.6.7 (default, Oct 21 2018, 08:56:20)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import libcloud
>>> libcloud.__version__
'2.7.0'
>>> from libcloud.compute.types import Provider
>>> from libcloud.compute.providers import get_driver
>>> cls = get_driver(Provider.EC2)
>>> access_key, secret_key = open('.keys').read().split()
>>> drv = cls(access_key, secret_key, region='us-west-2')
>>> drv.create_node(image='ami-0b74be4bc329b8a1b', size='t2.nano')
Traceback (most recent call last):
File "", line 1, in
File "/Users/jmg/work/openc2-aws-actuator/p/lib/python3.6/site-packages/libcloud/compute/drivers/ec2.py", line 1891, in create_node
'ImageId': image.id,
AttributeError: 'str' object has no attribute 'id'
>>> from mock import MagicMock
>>> img = MagicMock()
>>> img.id = 'ami-0b74be4bc329b8a1b'
>>> sizeobj = MagicMock()
>>> sizeobj.id = 't2.nano'
>>> drv.create_node(image=img, size=sizeobj, name='somename')
>>>
```
贡献指南
调研方向
从 libcloud/compute/drivers/ec2.py 的 create_node 入口点开始,检查 traceback 中显示的失败 ImageId 访问附近的代码。比较 GCP 和 Dummy 驱动如何解析字符串形式的 image ID 和 size ID。完成标准是 EC2 create_node 接受 image='ami-0b74be4bc329b8a1b' 和 size='t2.nano',同时也接受具有 id 属性的对象。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- aws, python
- 领域
- cloud
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100