You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by ma...@redhat.com on 2011/12/14 11:47:28 UTC

[PATCH 1/2] Add fetching of EC2 regions via API call (for drivers collection)

From: marios <ma...@redhat.com>


Signed-off-by: marios <ma...@redhat.com>
---
 server/lib/deltacloud/drivers/ec2/ec2_driver.rb |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
index 12f4fb3..da2cb3d 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -695,6 +695,12 @@ module Deltacloud
           end
         end
 
+        def providers(credentials, opts={})
+          ec2 = new_client(credentials)
+          providers = ec2.describe_regions.map{|r| Provider.new( {:id=>r, :name=>r,
+           :url=>"#{ENV['API_HOST']}:#{ENV['API_PORT']}#{settings.root_url}\;provider=#{r}" }) }
+        end
+
         def valid_credentials?(credentials)
           retval = true
           begin
-- 
1.7.6.4


Re: [PATCH 1/2] Add fetching of EC2 regions via API call (for drivers collection)

Posted by David Lutterkort <lu...@redhat.com>.
Hi Marios,

this is not all directly connected to your patch; but you made me look
at this code ;)

On Wed, 2011-12-14 at 12:47 +0200, marios@redhat.com wrote:
> From: marios <ma...@redhat.com>
> 
> 
> Signed-off-by: marios <ma...@redhat.com>
> ---
>  server/lib/deltacloud/drivers/ec2/ec2_driver.rb |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
> index 12f4fb3..da2cb3d 100644
> --- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
> +++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
> @@ -695,6 +695,12 @@ module Deltacloud
>            end
>          end
>  
> +        def providers(credentials, opts={})
> +          ec2 = new_client(credentials)
> +          providers = ec2.describe_regions.map{|r| Provider.new( {:id=>r, :name=>r,
> +           :url=>"#{ENV['API_HOST']}:#{ENV['API_PORT']}#{settings.root_url}\;provider=#{r}" }) }

The url should also include the protocol. (http/https)

Also, in the XML we now say

        <provider id="eu-west-1">
          <entrypoint kind="eu-west-1">localhost:3001/api;provider=eu-west-1</entrypoint>
        </provider>
        
Maybe we should change that to

        <provider id="eu-west-1">
           <entrypoint name="eu-west-1" href="http://localhost:3001/api;provider=eu-west-1"/>
        </provider>

Do we have any cases where provider/@id and entrypoint/@name would ever
differ ? And what is the exact meaning of these attributes ? Which of
them would I use as the X-Deltacloud-Provider ?

David



Re: [PATCH 1/2] Add fetching of EC2 regions via API call (for drivers collection)

Posted by Michal Fojtik <mf...@redhat.com>.
On Dec 14, 2011, at 11:47 AM, marios@redhat.com wrote:

ACK to both. Nicely done Marios. I never though that you can fetch
the list of providers using API. I think this will also make our YAML
file for EC2 obsolete.

  -- Michal


> From: marios <ma...@redhat.com>
> 
> 
> Signed-off-by: marios <ma...@redhat.com>
> ---
> server/lib/deltacloud/drivers/ec2/ec2_driver.rb |    6 ++++++
> 1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
> index 12f4fb3..da2cb3d 100644
> --- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
> +++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
> @@ -695,6 +695,12 @@ module Deltacloud
>           end
>         end
> 
> +        def providers(credentials, opts={})
> +          ec2 = new_client(credentials)
> +          providers = ec2.describe_regions.map{|r| Provider.new( {:id=>r, :name=>r,
> +           :url=>"#{ENV['API_HOST']}:#{ENV['API_PORT']}#{settings.root_url}\;provider=#{r}" }) }
> +        end
> +
>         def valid_credentials?(credentials)
>           retval = true
>           begin
> -- 
> 1.7.6.4
> 

------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org


[PATCH 2/2] Adds show.html.haml display of driver providers when available

Posted by ma...@redhat.com.
From: marios <ma...@redhat.com>


Signed-off-by: marios <ma...@redhat.com>
---
 server/views/drivers/show.html.haml |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/server/views/drivers/show.html.haml b/server/views/drivers/show.html.haml
index b11bcdd..062a5bc 100644
--- a/server/views/drivers/show.html.haml
+++ b/server/views/drivers/show.html.haml
@@ -12,9 +12,14 @@
     %li{ :'data-role' => 'list-divider'} Provider
     %li
       %p{ :'data-role' => 'fieldcontain'}
-        - providers = driver_provider(@driver).keys.collect { |k| k.to_s }.sort
-        - if providers.empty?
-          None
+        - if @providers
+          - @providers.each do |p|
+            %h3= p.id
+            %p= p.url
         - else
-          - providers.each do |k|
-            %p= k
+          - providers = driver_provider(@driver).keys.collect { |k| k.to_s }.sort
+          - if providers.empty?
+            None
+          - else
+            - providers.each do |k|
+              %p= k
-- 
1.7.6.4