Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
-
None
Description
Right now create_node in the EC2 driver requires instance size to be in a static list in order for a node to be created.
Given the almost constant influx of new instance types in EC2 and the relatively slow release cycle of Libcloud it would be nice to remove this requirement.
Maintaining the list in Libcloud is nice but it shouldn't block users from launching an instance with a new instance type.
Instead I believe the method should also accept a size string which gets passed directly to EC2 REST endpoints. Let EC2 raise an exception if an invalid instance type is provided.
I can provide a patch if this is agreeable?
Source location: https://github.com/apache/libcloud/blob/trunk/libcloud/compute/drivers/ec2.py#L1873
Suggested change diff:
Index: apache-libcloud-2.3.0/libcloud/compute/drivers/ec2.py =================================================================== — apache-libcloud-2.3.0.orig/libcloud/compute/drivers/ec2.py +++ apache-libcloud-2.3.0/libcloud/compute/drivers/ec2.py @@ -3907,12 +3907,18 @@ class BaseEC2NodeDriver(NodeDriver): """ image = kwargs["image"] size = kwargs["size"] + + try: + instance_type = size.id + except AttributeError: + instance_type = size + params = { 'Action': 'RunInstances', 'ImageId': image.id, 'MinCount': str(kwargs.get('ex_mincount', '1')), 'MaxCount': str(kwargs.get('ex_maxcount', '1')), - 'InstanceType': size.id + 'InstanceType': instance_type }
In this route if there is an invalid instance provided the error comes from EC2:
BaseHTTPError: InvalidParameterValue: Invalid value 'm5d.245xlarge' for InstanceType.