apache / apache/libcloud

ec2 driver does not support strings for size and image parameters

Abierto
#1,419 3 comentarios 0 reacciones 0 asignados Ver en GitHub
stale
Lenguaje dominante
Python
Estrellas
2.1k
Forks
931
Merge medio
1 d 2 h
PR fusionados (30 d)
4

Descripción

## 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')

>>>
```

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza en libcloud/compute/drivers/ec2.py, en el punto de entrada create_node, alrededor del acceso fallido a ImageId que se muestra en el traceback. Compara cómo los drivers GCP y Dummy resuelven los IDs de imagen y tamaño de tipo string. La tarea estará terminada cuando EC2 create_node acepte image='ami-0b74be4bc329b8a1b' y size='t2.nano', además de objetos con atributos id.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
aws, python
Área
cloud
Tipo de issue
Error
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.