apache / apache/libcloud

ec2 driver does not support strings for size and image parameters

オープン
#1,419 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
stale
主要言語
Python
スター
2.1k
フォーク
931
平均マージ
1日 2時間
マージ済み PR(30日)
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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。