deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1213767 - in /deltacloud/trunk/server: lib/deltacloud/base_driver/base_driver.rb lib/deltacloud/drivers/rhevm/rhevm_client.rb lib/deltacloud/models.rb lib/deltacloud/models/provider.rb lib/deltacloud/server.rb views/drivers/show.xml.haml
Date Tue, 13 Dec 2011 16:21:41 GMT
Author: mfojtik
Date: Tue Dec 13 16:21:40 2011
New Revision: 1213767

URL: http://svn.apache.org/viewvc?rev=1213767&view=rev
Log:
Core: Added support for dynamic provider list in /api/drivers/:id

Signed-off-by: Michal fojtik <mfojtik@redhat.com>

Added:
    deltacloud/trunk/server/lib/deltacloud/models/provider.rb
      - copied, changed from r1213766, deltacloud/trunk/server/lib/deltacloud/models.rb
Modified:
    deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb
    deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
    deltacloud/trunk/server/lib/deltacloud/models.rb
    deltacloud/trunk/server/lib/deltacloud/server.rb
    deltacloud/trunk/server/views/drivers/show.xml.haml

Modified: deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb?rev=1213767&r1=1213766&r2=1213767&view=diff
==============================================================================
--- deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb (original)
+++ deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb Tue Dec 13 16:21:40
2011
@@ -159,6 +159,7 @@ module Deltacloud
     # def delete_firewall(credentials, opts)
     # def create_firewall_rule(credentials, opts)
     # def delete_firewall_rule(credentials, opts)
+    # def providers(credentials)
     def realm(credentials, opts)
       realms = realms(credentials, opts).first if has_capability?(:realms)
     end

Modified: deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb?rev=1213767&r1=1213766&r2=1213767&view=diff
==============================================================================
--- deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb (original)
+++ deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb Tue Dec 13 16:21:40
2011
@@ -58,8 +58,8 @@ module RHEVM
       }
       headers.merge!(auth_header)
       if opts[:id]
-        return [] unless current_datacenter.cluster_ids.include?((vm/'cluster').first[:id])
         vm = Client::parse_response(RHEVM::client(@api_entrypoint)["/vms/%s" % opts[:id]].get(headers)).root
+        return [] unless current_datacenter.cluster_ids.include?((vm/'cluster').first[:id])
         [ RHEVM::VM::new(self, vm)]
       else
         Client::parse_response(RHEVM::client(@api_entrypoint)["/vms"].get(headers)).xpath('/vms/vm').collect
do |vm|
@@ -73,7 +73,7 @@ module RHEVM
       headers.merge!(auth_header)
       headers.merge!({:accept => 'application/xml'})
       vm = vms(:id => id)
-      raise RHEVMBackendException::new("Requested VM not found in datacenter #{self.current_datacenter.id}")
if vm.empty
+      raise RHEVMBackendException::new("Requested VM not found in datacenter #{self.current_datacenter.id}")
if vm.empty?
       if action==:delete
         RHEVM::client(@api_entrypoint)["/vms/%s" % id].delete(headers)
       else

Modified: deltacloud/trunk/server/lib/deltacloud/models.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/deltacloud/models.rb?rev=1213767&r1=1213766&r2=1213767&view=diff
==============================================================================
--- deltacloud/trunk/server/lib/deltacloud/models.rb (original)
+++ deltacloud/trunk/server/lib/deltacloud/models.rb Tue Dec 13 16:21:40 2011
@@ -29,3 +29,4 @@ require 'deltacloud/models/blob'
 require 'deltacloud/models/load_balancer'
 require 'deltacloud/models/firewall'
 require 'deltacloud/models/firewall_rule'
+require 'deltacloud/models/provider'

Copied: deltacloud/trunk/server/lib/deltacloud/models/provider.rb (from r1213766, deltacloud/trunk/server/lib/deltacloud/models.rb)
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/deltacloud/models/provider.rb?p2=deltacloud/trunk/server/lib/deltacloud/models/provider.rb&p1=deltacloud/trunk/server/lib/deltacloud/models.rb&r1=1213766&r2=1213767&rev=1213767&view=diff
==============================================================================
--- deltacloud/trunk/server/lib/deltacloud/models.rb (original)
+++ deltacloud/trunk/server/lib/deltacloud/models/provider.rb Tue Dec 13 16:21:40 2011
@@ -1,4 +1,3 @@
-#
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
 # this work for additional information regarding copyright ownership.  The
@@ -14,18 +13,15 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-require 'deltacloud/models/base_model'
-require 'deltacloud/models/realm'
-require 'deltacloud/models/image'
-require 'deltacloud/models/instance'
-require 'deltacloud/models/key'
-require 'deltacloud/models/address'
-require 'deltacloud/models/instance_address'
-require 'deltacloud/models/instance_profile'
-require 'deltacloud/models/storage_snapshot'
-require 'deltacloud/models/storage_volume'
-require 'deltacloud/models/bucket'
-require 'deltacloud/models/blob'
-require 'deltacloud/models/load_balancer'
-require 'deltacloud/models/firewall'
-require 'deltacloud/models/firewall_rule'
+# Model to store the hardware profile applied to an instance together with
+# any instance-specific overrides
+
+class Provider < BaseModel
+  attr_accessor :url
+  attr_accessor :name
+
+  def initialize(opts={})
+    super(opts)
+  end
+
+end

Modified: deltacloud/trunk/server/lib/deltacloud/server.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/deltacloud/server.rb?rev=1213767&r1=1213766&r2=1213767&view=diff
==============================================================================
--- deltacloud/trunk/server/lib/deltacloud/server.rb (original)
+++ deltacloud/trunk/server/lib/deltacloud/server.rb Tue Dec 13 16:21:40 2011
@@ -148,6 +148,7 @@ EOS
     param :id,      :string
     control do
       @name = params[:id].to_sym
+      @providers = driver.providers(credentials) if driver.respond_to? :providers
       @driver = settings.drivers[@name]
       return [404, "Driver #{@name} not found"] unless @driver
       respond_to do |format|

Modified: deltacloud/trunk/server/views/drivers/show.xml.haml
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/views/drivers/show.xml.haml?rev=1213767&r1=1213766&r2=1213767&view=diff
==============================================================================
--- deltacloud/trunk/server/views/drivers/show.xml.haml (original)
+++ deltacloud/trunk/server/views/drivers/show.xml.haml Tue Dec 13 16:21:40 2011
@@ -1,7 +1,12 @@
 %driver{ :href => driver_url(@name), :id => @name }
   %name<
     = @driver[:name]
-  - driver_provider(@driver).each do |prov, details|
-    %provider{ :id => prov }
-      - details.each do |kind, url|
-        %entrypoint{ :kind => kind }<=cdata(url)
+  - if @providers.nil?
+    - driver_provider(@driver).each do |prov, details|
+      %provider{ :id => prov }
+        - details.each do |kind, url|
+          %entrypoint{ :kind => kind }<=cdata(url)
+  - else
+    - @providers.each do |p|
+      %provider{ :id => p.id }
+        %entrypoint{ :kind => p.name }<=p.url



Mime
View raw message