During an EC2 create_instance call, two optional things might be done; tagging the instance with the name provided, and registering the new instance with a loadbalancer.
Unfortunately, there is a big problem with this; the instance ID does not always exist immediately after the ec2.launch_instances call returns. This seems to be a generic problem with EC2, as I've run into it several times. Because of this, we *cannot* tag the instance or register the instance with the load balancer right within the create_instance call, since we can't be sure the instance ID yet exists. Luckily, the loss of either function shouldn't be that huge; the name can never be retrieved (since there is no generic tag support), and you can always register an instance with a load balancer later. Therefore, totally remove these operations from create. Not only does this make create_instance more reliable, it restores the "one deltacloud API -> one cloud backend call" semantic that we try to preserve. Signed-off-by: Chris Lalancette <[email protected]> --- server/lib/deltacloud/drivers/ec2/ec2_driver.rb | 10 ---------- 1 files changed, 0 insertions(+), 10 deletions(-) diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb index 4edd989..d01113c 100644 --- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb +++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb @@ -214,16 +214,6 @@ module Deltacloud end safely do new_instance = convert_instance(ec2.launch_instances(image_id, instance_options).first) - # TODO: Rework this to use client_id for name instead of tag - # Tags should be keept as an optional feature - tag_instance(credentials, new_instance, opts[:name]) - # Register Instance to Load Balancer if load_balancer_id is set. - # This parameter is a feature parameter - if opts[:load_balancer_id] and opts[:load_balancer_id]!="" - lb = lb_register_instance(credentials, - {'id' => opts[:load_balancer_id], - 'instance_id' => new_instance.id}) - end new_instance end end -- 1.7.4.4
