You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2010/12/15 21:15:06 UTC
[PATCH core 08/10] Fixed storage_volume state to be amazon-ec2 compatible Added valid_credentials? to EC2 driver Removed public_ip feature from EC2 Fixed client when mounting storage_volume
From: Michal Fojtik <mf...@redhat.com>
---
client/lib/deltacloud.rb | 2 +-
server/lib/deltacloud/base_driver/features.rb | 6 ------
server/lib/deltacloud/drivers/ec2/ec2_driver.rb | 18 ++++++++++++++----
3 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb
index 1f04110..114b013 100644
--- a/client/lib/deltacloud.rb
+++ b/client/lib/deltacloud.rb
@@ -170,7 +170,7 @@ module DeltaCloud
end
if attribute.name == 'mount'
- obj.add_link!("instance", (attribute/"./instance/@id").first)
+ obj.add_link!("instance", (attribute/"./instance/@id").first.value)
obj.add_text!("device", (attribute/"./device/@name").first.value)
next
end
diff --git a/server/lib/deltacloud/base_driver/features.rb b/server/lib/deltacloud/base_driver/features.rb
index 6141d59..f20f635 100644
--- a/server/lib/deltacloud/base_driver/features.rb
+++ b/server/lib/deltacloud/base_driver/features.rb
@@ -191,11 +191,5 @@ module Deltacloud
end
end
- declare_feature :instances, :public_ip do
- operation :create do
- param :public_ip, :string, :optional
- end
- end
-
end
end
diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
index c05752b..039b39c 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -40,7 +40,6 @@ module Deltacloud
feature :instances, :user_data
feature :instances, :authentication_key
- feature :instances, :public_ip
feature :instances, :security_group
feature :images, :owner_id
feature :buckets, :bucket_location
@@ -179,7 +178,7 @@ module Deltacloud
instance_options = {}
instance_options.merge!(:user_data => opts[:user_data]) if opts[:user_data]
instance_options.merge!(:key_name => opts[:key_name]) if opts[:key_name]
- instance_options.merge!(:availability_zone => opts[:availability_zone]) if opts[:availability_zone]
+ instance_options.merge!(:availability_zone => opts[:realm_id]) if opts[:realm_id]
instance_options.merge!(:instance_type => opts[:hwp_id]) if opts[:hwp_id]
instance_options.merge!(:group_ids => opts[:security_group]) if opts[:security_group]
safely do
@@ -407,6 +406,16 @@ module Deltacloud
end
end
+ def valid_credentials?(credentials)
+ retval = true
+ begin
+ realms(credentials)
+ rescue Deltacloud::BackendError
+ retval = false
+ end
+ retval
+ end
+
private
def new_client(credentials, type = :ec2)
@@ -493,7 +502,7 @@ module Deltacloud
:instance_profile => InstanceProfile.new(instance[:aws_instance_type]),
:realm_id => instance[:aws_availability_zone],
:private_addresses => instance[:private_dns_name],
- :public_addresses => instance[:public_addresses]
+ :public_addresses => instance[:dns_name]
)
end
@@ -511,7 +520,8 @@ module Deltacloud
StorageVolume.new(
:id => volume[:aws_id],
:created => volume[:aws_created_at],
- :state => volume[:aws_status] ? volume[:aws_status].upcase : 'unknown',
+ # Fix IN_USE to be IN-USE
+ :state => volume[:aws_status] ? volume[:aws_status].tr('_', '-').upcase : 'unknown',
:capacity => volume[:aws_size],
:instance_id => volume[:aws_instance_id],
:realm_id => volume[:zone],
--
1.7.3.2