From: Jan Provaznik <[email protected]>

https://bugzilla.redhat.com/show_bug.cgi?id=641366

We explicitly check if there is a provider of selected type when building
template. This patch is temporary and code will be removed when we will support
multiple providers/builds.
---
 src/app/controllers/templates_controller.rb |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/app/controllers/templates_controller.rb 
b/src/app/controllers/templates_controller.rb
index 693780b..e06bae5 100644
--- a/src/app/controllers/templates_controller.rb
+++ b/src/app/controllers/templates_controller.rb
@@ -143,6 +143,17 @@ class TemplatesController < ApplicationController
 
     @tpl.upload_template unless @tpl.uploaded
     params[:targets].each do |target|
+      # FIXME: for beta release we check explicitly that provider and provider
+      # account exists
+      unless provider = Provider.find_by_cloud_type(target)
+        raise "There is no provider of '#{target}' type, you can add provider \
+on <a href=\"#{url_for :controller => 'provider'}\">the providers page.</a>"
+      end
+      if provider.cloud_accounts.empty?
+        raise "There is no provider account for '#{target}' provider, you can \
+add account on <a href=\"#{url_for :controller => 'provider', \
+:action => 'accounts', :id => provider.id}\">the provider accounts page</a>"
+      end
       begin
         Image.build(@tpl, target)
       rescue
-- 
1.7.2.3

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to