[ 
https://issues.apache.org/jira/browse/LIBCLOUD-1018?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sean Marlow updated LIBCLOUD-1018:
----------------------------------
    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:

 
{noformat}
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
}{noformat}
 

In this route if there is an invalid instance provided the error comes from EC2:

 
{noformat}
BaseHTTPError: InvalidParameterValue: Invalid value 'm5d.245xlarge' for 
InstanceType.{noformat}

  was:
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:

 
{noformat}
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
}{noformat}


> EC2 Create Node Size String
> ---------------------------
>
>                 Key: LIBCLOUD-1018
>                 URL: https://issues.apache.org/jira/browse/LIBCLOUD-1018
>             Project: Libcloud
>          Issue Type: Improvement
>            Reporter: Sean Marlow
>            Priority: Major
>
> 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:
>  
> {noformat}
> 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
> }{noformat}
>  
> In this route if there is an invalid instance provided the error comes from 
> EC2:
>  
> {noformat}
> BaseHTTPError: InvalidParameterValue: Invalid value 'm5d.245xlarge' for 
> InstanceType.{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to