[PATCH aggregator 1/2] InstanceController renamed to InstancesController
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
---
src/app/controllers/image_controller.rb | 2 +-
src/app/controllers/instance_controller.rb | 202 ----------------------
src/app/controllers/instances_controller.rb | 202 ++++++++++++++++++++++
src/app/helpers/instance_helper.rb | 33 ----
src/app/helpers/instances_helper.rb | 33 ++++
src/app/views/dashboard/summary.haml | 2 +-
src/app/views/instance/_instances.haml | 24 ---
src/app/views/instance/configure.haml | 23 ---
src/app/views/instance/create.haml | 2 -
src/app/views/instance/delete.haml | 2 -
src/app/views/instance/index.haml | 127 --------------
src/app/views/instance/new.haml | 19 --
src/app/views/instance/show.haml | 61 -------
src/app/views/instances/_instances.haml | 24 +++
src/app/views/instances/configure.haml | 23 +++
src/app/views/instances/create.haml | 2 +
src/app/views/instances/delete.haml | 2 +
src/app/views/instances/index.haml | 127 ++++++++++++++
src/app/views/instances/new.haml | 19 ++
src/app/views/instances/show.haml | 61 +++++++
src/app/views/pools/list.haml | 2 +-
src/config/navigation.rb | 2 +-
src/config/routes.rb | 2 +-
src/features/step_definitions/instance.rb | 8 +-
src/spec/controllers/instance_controller_spec.rb | 2 +-
25 files changed, 503 insertions(+), 503 deletions(-)
delete mode 100644 src/app/controllers/instance_controller.rb
create mode 100644 src/app/controllers/instances_controller.rb
delete mode 100644 src/app/helpers/instance_helper.rb
create mode 100644 src/app/helpers/instances_helper.rb
delete mode 100644 src/app/views/instance/_instances.haml
delete mode 100644 src/app/views/instance/configure.haml
delete mode 100644 src/app/views/instance/create.haml
delete mode 100644 src/app/views/instance/delete.haml
delete mode 100644 src/app/views/instance/index.haml
delete mode 100644 src/app/views/instance/new.haml
delete mode 100644 src/app/views/instance/show.haml
create mode 100644 src/app/views/instances/_instances.haml
create mode 100644 src/app/views/instances/configure.haml
create mode 100644 src/app/views/instances/create.haml
create mode 100644 src/app/views/instances/delete.haml
create mode 100644 src/app/views/instances/index.haml
create mode 100644 src/app/views/instances/new.haml
create mode 100644 src/app/views/instances/show.haml
diff --git a/src/app/controllers/image_controller.rb b/src/app/controllers/image_controller.rb
index 6e3f932..8cd8cbe 100644
--- a/src/app/controllers/image_controller.rb
+++ b/src/app/controllers/image_controller.rb
@@ -36,7 +36,7 @@ class ImageController < ApplicationController
def show
if params[:create_instance]
- redirect_to :controller => 'instance', :action => 'new', 'instance[image_id]' => (params[:ids] || []).first
+ redirect_to :controller => 'instances', :action => 'new', 'instance[image_id]' => (params[:ids] || []).first
end
require_privilege(Privilege::IMAGE_VIEW)
diff --git a/src/app/controllers/instance_controller.rb b/src/app/controllers/instance_controller.rb
deleted file mode 100644
index 0de246d..0000000
--- a/src/app/controllers/instance_controller.rb
+++ /dev/null
@@ -1,202 +0,0 @@
-#
-# Copyright (C) 2009 Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-# Filters added to this controller apply to all controllers in the application.
-# Likewise, all the methods added will be available for all controllers.
-
-require 'util/condormatic'
-
-class InstanceController < ApplicationController
- before_filter :require_user, :get_nav_items
- before_filter :instance, :only => [:show, :key]
- layout :layout
-
- def section_id
- 'runtime'
- end
-
- def layout
- return "aggregator" unless request.xhr?
- end
-
- def index
- @pools = Pool.list_for_user(@current_user, Privilege::INSTANCE_MODIFY)
-
- @order_dir = params[:order_dir] == 'desc' ? 'desc' : 'asc'
- @order_field = params[:order_field] || 'name'
-
- # we can't use pool.instances, because we need custom sorting
- @sorted_instances_by_pool = {}
- Instance.find(
- :all,
- :include => [:template, :hardware_profile, :owner, :pool],
- :order => @order_field + ' ' + @order_dir
- ).each do |inst|
- pool_id = inst.pool.id
- next unless @pools.find {|p| p.id == pool_id}
- (@sorted_instances_by_pool[pool_id] ||= []) << inst
- end
- end
-
- def show
- end
-
- def key
- unless @instance.instance_key.nil?
- send_data @instance.instance_key.pem,
- :filename => "#{(a)instance.instance_key.name}.pem",
- :type => "text/plain"
- return
- end
- flash[:warning] = "SSH Key not found for this Instance."
- redirect_to :action => "show", :id => @instance
- end
-
- def new
- @instance = Instance.new(params[:instance])
- require_privilege(Privilege::INSTANCE_MODIFY, @instance.pool) if @instance.pool
- # FIXME: we need to list only templates for particular user,
- # => TODO: add TEMPLATE_* permissions
- @templates = Template.paginate(
- :page => params[:page] || 1,
- :include => {:images => :replicated_images},
- :conditions => "replicated_images.uploaded = 't'"
- )
- end
-
- def configure
- @instance = Instance.new(params[:instance])
- require_privilege(Privilege::INSTANCE_MODIFY, @instance.pool)
- # FIXME: change template.architecture to match expected HWP arch strings
- if (@instance.template.architecture == "64-bit")
- arch_value = "x86_64"
- else
- arch_value = "i386"
- end
- @hardware_profiles = HardwareProfile.find(:all, :include => :architecture,
- :conditions => {:provider_id => nil,
- "hardware_profile_properties.value" => arch_value})
- end
-
- def create
- if params[:cancel]
- redirect_to :action => 'new', :instance => {:pool_id => params[:instance][:pool_id]}
- return
- end
-
- @instance = Instance.new(params[:instance])
- @instance.state = Instance::STATE_NEW
- @instance.owner = current_user
-
- require_privilege(Privilege::INSTANCE_MODIFY,
- Pool.find((a)instance.pool_id))
- #FIXME: This should probably be in a transaction
- if @instance.save!
- @task = InstanceTask.new({:user => current_user,
- :task_target => @instance,
- :action => InstanceTask::ACTION_CREATE})
- if @task.save
- condormatic_instance_create(@task)
- if Quota.can_start_instance?(@instance, nil)
- flash[:notice] = "Instance added."
- else
- flash[:warning] = "Quota Exceeded: Instance will not start until you have free quota"
- end
- else
- @pool = @instance.pool
- render :action => 'configure'
- end
- redirect_to :action => 'index'
- else
- @hardware_profiles = HardwareProfile.all
- render :action => 'configure'
- end
- end
-
- def instance_action
- params.keys.each do |param|
- if param =~ /^launch_instance_(\d+)$/
- redirect_to :action => 'new', 'instance[pool_id]' => $1
- return
- end
- end
-
- @instance = Instance.find((params[:id] || []).first)
- require_privilege(Privilege::INSTANCE_CONTROL,@instance.pool)
-
- if params[:instance_details]
- render :action => 'show'
- return
- end
-
- if params[:remove_failed]
- action = remove_failed
- else
- # action list will be longer (restart, start, stop..)
- action = if params[:shutdown]
- 'stop'
- #elsif params[:restart]
- # 'restart'
- end
-
- unless @instance.valid_action?(action)
- raise ActionError.new("'#{action}' is an invalid action.")
- end
-
- # not sure if task is used as everything goes through condor
- #permissons check here
- @task = @instance.queue_action(@current_user, action)
- unless @task
- raise ActionError.new("#{action} cannot be performed on this instance.")
- end
-
- case action
- when 'stop'
- condormatic_instance_stop(@task)
- when 'destroy'
- condormatic_instance_destroy(@task)
- when 'start'
- condormatic_instance_create(@task)
- else
- raise ActionError.new("Sorry, action '#{action}' is currently not supported by condor backend.")
- end
- end
-
- flash[:notice] = "#{(a)instance.name}: #{action} was successfully queued."
- redirect_to :action => 'index'
- end
-
- def delete
- end
-
- def remove_failed
- action ='remove failed'
- raise ActionError.new("#{action} cannot be performed on this instance.") unless
- @instance.state == Instance::STATE_ERROR
- condormatic_instance_reset_error(@instance)
- action
- end
-
- private
-
- def instance
- @instance = Instance.find(params[:id])
- require_privilege(Privilege::INSTANCE_VIEW, @instance.pool)
- end
-
-end
diff --git a/src/app/controllers/instances_controller.rb b/src/app/controllers/instances_controller.rb
new file mode 100644
index 0000000..3ffb287
--- /dev/null
+++ b/src/app/controllers/instances_controller.rb
@@ -0,0 +1,202 @@
+#
+# Copyright (C) 2009 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+require 'util/condormatic'
+
+class InstancesController < ApplicationController
+ before_filter :require_user, :get_nav_items
+ before_filter :instance, :only => [:show, :key]
+ layout :layout
+
+ def section_id
+ 'runtime'
+ end
+
+ def layout
+ return "aggregator" unless request.xhr?
+ end
+
+ def index
+ @pools = Pool.list_for_user(@current_user, Privilege::INSTANCE_MODIFY)
+
+ @order_dir = params[:order_dir] == 'desc' ? 'desc' : 'asc'
+ @order_field = params[:order_field] || 'name'
+
+ # we can't use pool.instances, because we need custom sorting
+ @sorted_instances_by_pool = {}
+ Instance.find(
+ :all,
+ :include => [:template, :hardware_profile, :owner, :pool],
+ :order => @order_field + ' ' + @order_dir
+ ).each do |inst|
+ pool_id = inst.pool.id
+ next unless @pools.find {|p| p.id == pool_id}
+ (@sorted_instances_by_pool[pool_id] ||= []) << inst
+ end
+ end
+
+ def show
+ end
+
+ def key
+ unless @instance.instance_key.nil?
+ send_data @instance.instance_key.pem,
+ :filename => "#{(a)instance.instance_key.name}.pem",
+ :type => "text/plain"
+ return
+ end
+ flash[:warning] = "SSH Key not found for this Instance."
+ redirect_to :action => "show", :id => @instance
+ end
+
+ def new
+ @instance = Instance.new(params[:instance])
+ require_privilege(Privilege::INSTANCE_MODIFY, @instance.pool) if @instance.pool
+ # FIXME: we need to list only templates for particular user,
+ # => TODO: add TEMPLATE_* permissions
+ @templates = Template.paginate(
+ :page => params[:page] || 1,
+ :include => {:images => :replicated_images},
+ :conditions => "replicated_images.uploaded = 't'"
+ )
+ end
+
+ def configure
+ @instance = Instance.new(params[:instance])
+ require_privilege(Privilege::INSTANCE_MODIFY, @instance.pool)
+ # FIXME: change template.architecture to match expected HWP arch strings
+ if (@instance.template.architecture == "64-bit")
+ arch_value = "x86_64"
+ else
+ arch_value = "i386"
+ end
+ @hardware_profiles = HardwareProfile.find(:all, :include => :architecture,
+ :conditions => {:provider_id => nil,
+ "hardware_profile_properties.value" => arch_value})
+ end
+
+ def create
+ if params[:cancel]
+ redirect_to :action => 'new', :instance => {:pool_id => params[:instance][:pool_id]}
+ return
+ end
+
+ @instance = Instance.new(params[:instance])
+ @instance.state = Instance::STATE_NEW
+ @instance.owner = current_user
+
+ require_privilege(Privilege::INSTANCE_MODIFY,
+ Pool.find((a)instance.pool_id))
+ #FIXME: This should probably be in a transaction
+ if @instance.save!
+ @task = InstanceTask.new({:user => current_user,
+ :task_target => @instance,
+ :action => InstanceTask::ACTION_CREATE})
+ if @task.save
+ condormatic_instance_create(@task)
+ if Quota.can_start_instance?(@instance, nil)
+ flash[:notice] = "Instance added."
+ else
+ flash[:warning] = "Quota Exceeded: Instance will not start until you have free quota"
+ end
+ else
+ @pool = @instance.pool
+ render :action => 'configure'
+ end
+ redirect_to :action => 'index'
+ else
+ @hardware_profiles = HardwareProfile.all
+ render :action => 'configure'
+ end
+ end
+
+ def instance_action
+ params.keys.each do |param|
+ if param =~ /^launch_instance_(\d+)$/
+ redirect_to :action => 'new', 'instance[pool_id]' => $1
+ return
+ end
+ end
+
+ @instance = Instance.find((params[:id] || []).first)
+ require_privilege(Privilege::INSTANCE_CONTROL,@instance.pool)
+
+ if params[:instance_details]
+ render :action => 'show'
+ return
+ end
+
+ if params[:remove_failed]
+ action = remove_failed
+ else
+ # action list will be longer (restart, start, stop..)
+ action = if params[:shutdown]
+ 'stop'
+ #elsif params[:restart]
+ # 'restart'
+ end
+
+ unless @instance.valid_action?(action)
+ raise ActionError.new("'#{action}' is an invalid action.")
+ end
+
+ # not sure if task is used as everything goes through condor
+ #permissons check here
+ @task = @instance.queue_action(@current_user, action)
+ unless @task
+ raise ActionError.new("#{action} cannot be performed on this instance.")
+ end
+
+ case action
+ when 'stop'
+ condormatic_instance_stop(@task)
+ when 'destroy'
+ condormatic_instance_destroy(@task)
+ when 'start'
+ condormatic_instance_create(@task)
+ else
+ raise ActionError.new("Sorry, action '#{action}' is currently not supported by condor backend.")
+ end
+ end
+
+ flash[:notice] = "#{(a)instance.name}: #{action} was successfully queued."
+ redirect_to :action => 'index'
+ end
+
+ def delete
+ end
+
+ def remove_failed
+ action ='remove failed'
+ raise ActionError.new("#{action} cannot be performed on this instance.") unless
+ @instance.state == Instance::STATE_ERROR
+ condormatic_instance_reset_error(@instance)
+ action
+ end
+
+ private
+
+ def instance
+ @instance = Instance.find(params[:id])
+ require_privilege(Privilege::INSTANCE_VIEW, @instance.pool)
+ end
+
+end
diff --git a/src/app/helpers/instance_helper.rb b/src/app/helpers/instance_helper.rb
deleted file mode 100644
index fea3cf4..0000000
--- a/src/app/helpers/instance_helper.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright (C) 2009 Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-# Filters added to this controller apply to all controllers in the application.
-# Likewise, all the methods added will be available for all controllers.
-
-module InstanceHelper
- def owner_name(inst)
- return '' unless inst.owner
- # if last_name is set, use full name,
- # else use login
- if inst.owner.last_name.blank?
- inst.owner.login
- else
- "#{inst.owner.first_name} #{inst.owner.last_name}"
- end
- end
-end
diff --git a/src/app/helpers/instances_helper.rb b/src/app/helpers/instances_helper.rb
new file mode 100644
index 0000000..740b01f
--- /dev/null
+++ b/src/app/helpers/instances_helper.rb
@@ -0,0 +1,33 @@
+#
+# Copyright (C) 2009 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+module InstancesHelper
+ def owner_name(inst)
+ return '' unless inst.owner
+ # if last_name is set, use full name,
+ # else use login
+ if inst.owner.last_name.blank?
+ inst.owner.login
+ else
+ "#{inst.owner.first_name} #{inst.owner.last_name}"
+ end
+ end
+end
diff --git a/src/app/views/dashboard/summary.haml b/src/app/views/dashboard/summary.haml
index ff116d4..5eb49a5 100644
--- a/src/app/views/dashboard/summary.haml
+++ b/src/app/views/dashboard/summary.haml
@@ -35,7 +35,7 @@
Add a Provider
%a{:href => url_for(:controller => "users", :action => "new")}
Create a User
- %a{:href => url_for(:controller => "instance", :action => "index")}
+ %a{:href => url_for(:controller => "instances", :action => "index")}
View Instances
- else
%a{:href => url_for(:controller => "", :action => "")}
diff --git a/src/app/views/instance/_instances.haml b/src/app/views/instance/_instances.haml
deleted file mode 100644
index 5af1838..0000000
--- a/src/app/views/instance/_instances.haml
+++ /dev/null
@@ -1,24 +0,0 @@
-- columns = [ |
- {:id => 'id', :header => ''}, |
- {:header => 'Actions'}, |
- {:id => 'name', :header => 'Name', :sortable => true}, |
- {:header => 'Details'}, |
- {:id => 'template', :header => 'Template'}, |
- {:id => 'state', :sortable => true, :header => 'State'}, |
- {:id => 'time_last_running', :header => 'Time last running'}, |
-] |
-
-- opts = { :order => @order,
- :order_dir => @order_dir,
- :title => "Instances for #{(a)pool.name}",
- :check_all => 'id' }
-
-= paginated_table('instances_table', columns, @instances, opts) do |rec|
- %tr{:class => "#{cycle('even', 'odd')}"}
- %td= check_box_tag 'ids[]', rec.id
- %td= rec.get_action_list.map {|action| link_to action, :controller => "instance", :action => "instance_action", :id => rec, :instance_action => action}.join(" | ")
- %td= rec.name
- %td Details
- %td= rec.template.name
- %td= rec.state
- %td= rec.time_last_running
diff --git a/src/app/views/instance/configure.haml b/src/app/views/instance/configure.haml
deleted file mode 100644
index 809c044..0000000
--- a/src/app/views/instance/configure.haml
+++ /dev/null
@@ -1,23 +0,0 @@
-%h2 Launch instance
-- form_for @instance, :url => {:action => 'create'} do
- = hidden_field :instance, :template_id
- = hidden_field :instance, :pool_id
- %ul
- %li
- = label :instance, :name
- = text_field :instance, :name
- %li
- = label :instance, :template
- = text_field_tag :template_name, @instance.template ? @instance.template.name : '', :disabled => true
- %li
- = label :instance, :pool
- = text_field_tag :pool_name, @instance.pool ? @instance.pool.name : '', :disabled => true
- %li
- = label :instance, :hardware_profile
- = select :instance, :hardware_profile_id, @hardware_profiles.map {|p| [ p.name, p.id ]}, { :include_blank => false }
- %li
- = label :instance, :realm
- = select :instance, :realm_id, @instance.pool.realms.map {|r| [ r.name, r.id ]}, { :include_blank => true }
-
- = submit_tag 'Cancel', :name => 'cancel'
- = submit_tag 'Launch', :name => 'launch'
diff --git a/src/app/views/instance/create.haml b/src/app/views/instance/create.haml
deleted file mode 100644
index 6fd9474..0000000
--- a/src/app/views/instance/create.haml
+++ /dev/null
@@ -1,2 +0,0 @@
-%h1 Instance#create
-%p Find me in app/views/instance/create.html.erb
diff --git a/src/app/views/instance/delete.haml b/src/app/views/instance/delete.haml
deleted file mode 100644
index 63de29b..0000000
--- a/src/app/views/instance/delete.haml
+++ /dev/null
@@ -1,2 +0,0 @@
-%h1 Instance#delete
-%p Find me in app/views/instance/delete.html.erb
diff --git a/src/app/views/instance/index.haml b/src/app/views/instance/index.haml
deleted file mode 100644
index 83690b7..0000000
--- a/src/app/views/instance/index.haml
+++ /dev/null
@@ -1,127 +0,0 @@
-- columns = [ |
- {:name => '', :sortable => false}, |
- {:name => 'STATUS', :sortable => false}, |
- {:name => 'VM NAME', :sort_attr => 'name'}, |
- {:name => 'TYPE', :sort_attr => 'hardware_profiles.name'}, |
- {:name => 'TEMPLATE', :sort_attr => 'templates.name'}, |
- {:name => 'PUBLIC ADDRESS', :sort_attr => 'public_addresses'}, |
- {:name => 'PROVIDER', :sortable => false}, |
- {:name => 'CREATED BY', :sort_attr => 'users.last_name'}, |
-] |
-
-- pool_columns = [ |
- { :name => "Pool name", :sort_attr => :name }, |
- { :name => "Alerts", :sortable => false }, |
- { :name => "Capacity", :sortable => false }, |
- { :name => "Zone", :sort_attr => "zones.name" } |
-] |
-
-
-- form_tag(:action => 'instance_action') do
- .actionsidebar.grid_3
- %dl
- %dt Actions
- %dd
- %h5 Control Instances
- %ul
- %li.start.disabled
- %span
- = submit_tag "Start", :name => "start", :class => "icon", :disabled => true
- %li.stop.disabled
- %span
- = submit_tag "Stop", :name => "stop", :class => "icon", :disabled => true
- %li.restart.disabled
- %span
- = submit_tag "Restart", :name => "restart", :class => "icon", :disabled => true
- %li.shutdown
- %span
- = submit_tag "Shutdown", :name => "shutdown", :class => "icon"
- %li.console.disabled
- %span
- = submit_tag "Console Access", :name => "console_access", :class => "icon", :disabled => true
- %li.VD.disabled
- %span
- = submit_tag "Virtual Desktop", :name => "vd", :class => "icon", :disabled => true
- %li.delete
- %span
- = submit_tag "Remove Failed", :name => "remove_failed", :class => "icon"
- %dd
- %h5 Manage Instances
- %ul
- %li.snapshot.disabled
- %span
- = submit_tag "Create Snapshot", :name => "snapshot", :class => "icon", :disabled => true
- %li.grantaccess.disabled
- %span
- = submit_tag "Grant Access", :name => "grantaccess", :class => "icon", :disabled => true
- %li.info
- %span
- = submit_tag "Instance Details", :name => "instance_details", :class => "icon"
- %li.request_help.disabled
- %span
- = submit_tag "Request Help", :name => "request_help", :class => "icon", :disabled => true
-
- .grid_5
- %h2 My Quota
- %table
- %thead
- %tr
- %th % Quota Used
- %th
- Quota
- %span.small (Instances)
- %tbody
- %tr
- - quota = current_user.quota.maximum_running_instances
- %td
- - if quota.respond_to? '>' and quota > 0
- = "%.2f" % ((current_user.quota.running_instances / quota.to_f) * 100)
- - else
- = 0
- %td
- = quota or "unlimited"
- .grid_8
- %h2 Pool Status
- %table
- =sortable_table_header pool_columns
- - @pools.each do |pool|
- %tr
- %td
- = pool.name
- %td N/A
- %td.capacity
- %span.good
- %td
- =pool.zone.name
- .grid_13
- %h2 Instances by Pool
- - @pools.each do |pool|
- .grid_6.alpha.poolname
- %h4= pool.name
- = link_to image_tag("blnk.png", :border=>0) + "Launch Instance", {:controller => "instance", :action => "new", 'instance[pool_id]' => pool.id}, :class => "button iconbutton fr"
-
- .grid_4.poolfilter
- %input{:type => "radio", :id => "all_" + pool.id.to_s, :name => "filter_" + pool.id.to_s}
- %label{:for => "all_" + pool.id.to_s} Show All
- %input{:type => "radio", :id => "summary_" + pool.id.to_s, :name => "filter_" + pool.id.to_s}
- %label{:for => "summary_" + pool.id.to_s} Summary View
- .search.grid_3.omega
- %input{:type => "search", :placeholder => "Search Instance"}
- %button.action Search
- %table.gap
- = sortable_table_header(columns)
- %tbody
- - if not instances = @sorted_instances_by_pool[pool.id] or instances.empty?
- %tr
- %td{:colspan => 8} No Instances
- - else
- - instances.each do |inst|
- %tr
- %td= radio_button_tag 'id[]', inst.id
- %td= inst.state
- %td= inst.name
- %td= inst.hardware_profile.name
- %td= inst.template.name
- %td= inst.public_addresses
- %td= inst.cloud_account ? inst.cloud_account.provider.name : ''
- %td= owner_name(inst)
diff --git a/src/app/views/instance/new.haml b/src/app/views/instance/new.haml
deleted file mode 100644
index 8038a2b..0000000
--- a/src/app/views/instance/new.haml
+++ /dev/null
@@ -1,19 +0,0 @@
-%h3 Show Templates
-%hr
-%ul
- - @templates.each do |tpl|
- %li
- - form_tag(:action => 'configure') do
- = hidden_field :instance, :template_id, :value => tpl.id
- = hidden_field :instance, :pool_id, :value => @instance.pool.id
- = image_tag "platform_#{tpl.platform}.png", :size => "32x32", :alt => tpl.platform
- %h3= tpl.name
- %p= tpl.summary
- %p
- %label Group:
- System
- %label Version:
- 2.5
- = submit_tag 'Launch', :name => 'launch'
-= will_paginate(@templates)
-= page_entries_info(@templates)
diff --git a/src/app/views/instance/show.haml b/src/app/views/instance/show.haml
deleted file mode 100644
index cb34dde..0000000
--- a/src/app/views/instance/show.haml
+++ /dev/null
@@ -1,61 +0,0 @@
-%h2 Instance Details
-- form_tag(:action => 'index') do
- %ul
- %li
- = label_tag :name, 'Name'
- %span= @instance.name
- %li
- = label_tag :status, 'Status'
- %span= @instance.state
- %li
- = label_tag :public_addresses, 'Public Addresses'
- %span= @instance.public_addresses
- %li
- = label_tag :private_addresses, 'Private Addresses'
- %span= @instance.private_addresses
- %li
- = label_tag :operating_system, 'Operating system'
- %span= "#{(a)instance.template.xml.platform} #{(a)instance.template.xml.platform_version}"
- %li
- = label_tag :provider, 'Provider'
- %span= @instance.cloud_account.provider.name if @instance.cloud_account
- %li
- = label_tag :base_template, 'Base Template'
- %span= @instance.template.name
- %li
- = label_tag :architecture, 'Architecture'
- %span= @instance.hardware_profile.architecture.value
- %li
- = label_tag :memory, 'Memory'
- %span= @instance.hardware_profile.memory.value
- %li
- = label_tag :storage, 'Storage'
- %span= @instance.hardware_profile.storage.value
- %li
- = label_tag :instantiation_time, 'Instantiation Time'
- %span= @instance.created_at.strftime("%d-%b-%Y %H:%M:%S")
- %li
- = label_tag :uptime, 'Uptime'
- %span= @instance.total_state_time((a)instance.state)
- %li
- = label_tag :current_alerts, 'Current Alerts'
- %span= 0
- %li
- = label_tag :console_connection, 'Console Connection'
- %span= 'via SSH'
- - unless @instance.instance_key_id.nil?
- %li
- = label_tag :instance_key, 'SSH key'
- %span= link_to("Download", { :controller => "instance", :action => "key", :id => @instance })
- %li
- = label_tag :owner, 'Owner'
- %span= "#{(a)instance.owner.first_name} #{(a)instance.owner.last_name}"
- %li
- = label_tag :shared_to, 'Shared to'
- %span= "N/A"
- - if @instance.state == Instance::STATE_ERROR
- %li
- = label_tag :error, 'Error'
- %span= @instance.last_error
-
- = submit_tag 'Back', :name => 'back'
diff --git a/src/app/views/instances/_instances.haml b/src/app/views/instances/_instances.haml
new file mode 100644
index 0000000..5dbca9f
--- /dev/null
+++ b/src/app/views/instances/_instances.haml
@@ -0,0 +1,24 @@
+- columns = [ |
+ {:id => 'id', :header => ''}, |
+ {:header => 'Actions'}, |
+ {:id => 'name', :header => 'Name', :sortable => true}, |
+ {:header => 'Details'}, |
+ {:id => 'template', :header => 'Template'}, |
+ {:id => 'state', :sortable => true, :header => 'State'}, |
+ {:id => 'time_last_running', :header => 'Time last running'}, |
+] |
+
+- opts = { :order => @order,
+ :order_dir => @order_dir,
+ :title => "Instances for #{(a)pool.name}",
+ :check_all => 'id' }
+
+= paginated_table('instances_table', columns, @instances, opts) do |rec|
+ %tr{:class => "#{cycle('even', 'odd')}"}
+ %td= check_box_tag 'ids[]', rec.id
+ %td= rec.get_action_list.map {|action| link_to action, :controller => "instances", :action => "instance_action", :id => rec, :instance_action => action}.join(" | ")
+ %td= rec.name
+ %td Details
+ %td= rec.template.name
+ %td= rec.state
+ %td= rec.time_last_running
diff --git a/src/app/views/instances/configure.haml b/src/app/views/instances/configure.haml
new file mode 100644
index 0000000..809c044
--- /dev/null
+++ b/src/app/views/instances/configure.haml
@@ -0,0 +1,23 @@
+%h2 Launch instance
+- form_for @instance, :url => {:action => 'create'} do
+ = hidden_field :instance, :template_id
+ = hidden_field :instance, :pool_id
+ %ul
+ %li
+ = label :instance, :name
+ = text_field :instance, :name
+ %li
+ = label :instance, :template
+ = text_field_tag :template_name, @instance.template ? @instance.template.name : '', :disabled => true
+ %li
+ = label :instance, :pool
+ = text_field_tag :pool_name, @instance.pool ? @instance.pool.name : '', :disabled => true
+ %li
+ = label :instance, :hardware_profile
+ = select :instance, :hardware_profile_id, @hardware_profiles.map {|p| [ p.name, p.id ]}, { :include_blank => false }
+ %li
+ = label :instance, :realm
+ = select :instance, :realm_id, @instance.pool.realms.map {|r| [ r.name, r.id ]}, { :include_blank => true }
+
+ = submit_tag 'Cancel', :name => 'cancel'
+ = submit_tag 'Launch', :name => 'launch'
diff --git a/src/app/views/instances/create.haml b/src/app/views/instances/create.haml
new file mode 100644
index 0000000..6fd9474
--- /dev/null
+++ b/src/app/views/instances/create.haml
@@ -0,0 +1,2 @@
+%h1 Instance#create
+%p Find me in app/views/instance/create.html.erb
diff --git a/src/app/views/instances/delete.haml b/src/app/views/instances/delete.haml
new file mode 100644
index 0000000..63de29b
--- /dev/null
+++ b/src/app/views/instances/delete.haml
@@ -0,0 +1,2 @@
+%h1 Instance#delete
+%p Find me in app/views/instance/delete.html.erb
diff --git a/src/app/views/instances/index.haml b/src/app/views/instances/index.haml
new file mode 100644
index 0000000..9c2efb8
--- /dev/null
+++ b/src/app/views/instances/index.haml
@@ -0,0 +1,127 @@
+- columns = [ |
+ {:name => '', :sortable => false}, |
+ {:name => 'STATUS', :sortable => false}, |
+ {:name => 'VM NAME', :sort_attr => 'name'}, |
+ {:name => 'TYPE', :sort_attr => 'hardware_profiles.name'}, |
+ {:name => 'TEMPLATE', :sort_attr => 'templates.name'}, |
+ {:name => 'PUBLIC ADDRESS', :sort_attr => 'public_addresses'}, |
+ {:name => 'PROVIDER', :sortable => false}, |
+ {:name => 'CREATED BY', :sort_attr => 'users.last_name'}, |
+] |
+
+- pool_columns = [ |
+ { :name => "Pool name", :sort_attr => :name }, |
+ { :name => "Alerts", :sortable => false }, |
+ { :name => "Capacity", :sortable => false }, |
+ { :name => "Zone", :sort_attr => "zones.name" } |
+] |
+
+
+- form_tag(:action => 'instance_action') do
+ .actionsidebar.grid_3
+ %dl
+ %dt Actions
+ %dd
+ %h5 Control Instances
+ %ul
+ %li.start.disabled
+ %span
+ = submit_tag "Start", :name => "start", :class => "icon", :disabled => true
+ %li.stop.disabled
+ %span
+ = submit_tag "Stop", :name => "stop", :class => "icon", :disabled => true
+ %li.restart.disabled
+ %span
+ = submit_tag "Restart", :name => "restart", :class => "icon", :disabled => true
+ %li.shutdown
+ %span
+ = submit_tag "Shutdown", :name => "shutdown", :class => "icon"
+ %li.console.disabled
+ %span
+ = submit_tag "Console Access", :name => "console_access", :class => "icon", :disabled => true
+ %li.VD.disabled
+ %span
+ = submit_tag "Virtual Desktop", :name => "vd", :class => "icon", :disabled => true
+ %li.delete
+ %span
+ = submit_tag "Remove Failed", :name => "remove_failed", :class => "icon"
+ %dd
+ %h5 Manage Instances
+ %ul
+ %li.snapshot.disabled
+ %span
+ = submit_tag "Create Snapshot", :name => "snapshot", :class => "icon", :disabled => true
+ %li.grantaccess.disabled
+ %span
+ = submit_tag "Grant Access", :name => "grantaccess", :class => "icon", :disabled => true
+ %li.info
+ %span
+ = submit_tag "Instance Details", :name => "instance_details", :class => "icon"
+ %li.request_help.disabled
+ %span
+ = submit_tag "Request Help", :name => "request_help", :class => "icon", :disabled => true
+
+ .grid_5
+ %h2 My Quota
+ %table
+ %thead
+ %tr
+ %th % Quota Used
+ %th
+ Quota
+ %span.small (Instances)
+ %tbody
+ %tr
+ - quota = current_user.quota.maximum_running_instances
+ %td
+ - if quota.respond_to? '>' and quota > 0
+ = "%.2f" % ((current_user.quota.running_instances / quota.to_f) * 100)
+ - else
+ = 0
+ %td
+ = quota or "unlimited"
+ .grid_8
+ %h2 Pool Status
+ %table
+ =sortable_table_header pool_columns
+ - @pools.each do |pool|
+ %tr
+ %td
+ = pool.name
+ %td N/A
+ %td.capacity
+ %span.good
+ %td
+ =pool.zone.name
+ .grid_13
+ %h2 Instances by Pool
+ - @pools.each do |pool|
+ .grid_6.alpha.poolname
+ %h4= pool.name
+ = link_to image_tag("blnk.png", :border=>0) + "Launch Instance", {:controller => "instances", :action => "new", 'instance[pool_id]' => pool.id}, :class => "button iconbutton fr"
+
+ .grid_4.poolfilter
+ %input{:type => "radio", :id => "all_" + pool.id.to_s, :name => "filter_" + pool.id.to_s}
+ %label{:for => "all_" + pool.id.to_s} Show All
+ %input{:type => "radio", :id => "summary_" + pool.id.to_s, :name => "filter_" + pool.id.to_s}
+ %label{:for => "summary_" + pool.id.to_s} Summary View
+ .search.grid_3.omega
+ %input{:type => "search", :placeholder => "Search Instance"}
+ %button.action Search
+ %table.gap
+ = sortable_table_header(columns)
+ %tbody
+ - if not instances = @sorted_instances_by_pool[pool.id] or instances.empty?
+ %tr
+ %td{:colspan => 8} No Instances
+ - else
+ - instances.each do |inst|
+ %tr
+ %td= radio_button_tag 'id[]', inst.id
+ %td= inst.state
+ %td= inst.name
+ %td= inst.hardware_profile.name
+ %td= inst.template.name
+ %td= inst.public_addresses
+ %td= inst.cloud_account ? inst.cloud_account.provider.name : ''
+ %td= owner_name(inst)
diff --git a/src/app/views/instances/new.haml b/src/app/views/instances/new.haml
new file mode 100644
index 0000000..8038a2b
--- /dev/null
+++ b/src/app/views/instances/new.haml
@@ -0,0 +1,19 @@
+%h3 Show Templates
+%hr
+%ul
+ - @templates.each do |tpl|
+ %li
+ - form_tag(:action => 'configure') do
+ = hidden_field :instance, :template_id, :value => tpl.id
+ = hidden_field :instance, :pool_id, :value => @instance.pool.id
+ = image_tag "platform_#{tpl.platform}.png", :size => "32x32", :alt => tpl.platform
+ %h3= tpl.name
+ %p= tpl.summary
+ %p
+ %label Group:
+ System
+ %label Version:
+ 2.5
+ = submit_tag 'Launch', :name => 'launch'
+= will_paginate(@templates)
+= page_entries_info(@templates)
diff --git a/src/app/views/instances/show.haml b/src/app/views/instances/show.haml
new file mode 100644
index 0000000..33b2897
--- /dev/null
+++ b/src/app/views/instances/show.haml
@@ -0,0 +1,61 @@
+%h2 Instance Details
+- form_tag(:action => 'index') do
+ %ul
+ %li
+ = label_tag :name, 'Name'
+ %span= @instance.name
+ %li
+ = label_tag :status, 'Status'
+ %span= @instance.state
+ %li
+ = label_tag :public_addresses, 'Public Addresses'
+ %span= @instance.public_addresses
+ %li
+ = label_tag :private_addresses, 'Private Addresses'
+ %span= @instance.private_addresses
+ %li
+ = label_tag :operating_system, 'Operating system'
+ %span= "#{(a)instance.template.xml.platform} #{(a)instance.template.xml.platform_version}"
+ %li
+ = label_tag :provider, 'Provider'
+ %span= @instance.cloud_account.provider.name if @instance.cloud_account
+ %li
+ = label_tag :base_template, 'Base Template'
+ %span= @instance.template.name
+ %li
+ = label_tag :architecture, 'Architecture'
+ %span= @instance.hardware_profile.architecture.value
+ %li
+ = label_tag :memory, 'Memory'
+ %span= @instance.hardware_profile.memory.value
+ %li
+ = label_tag :storage, 'Storage'
+ %span= @instance.hardware_profile.storage.value
+ %li
+ = label_tag :instantiation_time, 'Instantiation Time'
+ %span= @instance.created_at.strftime("%d-%b-%Y %H:%M:%S")
+ %li
+ = label_tag :uptime, 'Uptime'
+ %span= @instance.total_state_time((a)instance.state)
+ %li
+ = label_tag :current_alerts, 'Current Alerts'
+ %span= 0
+ %li
+ = label_tag :console_connection, 'Console Connection'
+ %span= 'via SSH'
+ - unless @instance.instance_key_id.nil?
+ %li
+ = label_tag :instance_key, 'SSH key'
+ %span= link_to("Download", { :controller => "instances", :action => "key", :id => @instance })
+ %li
+ = label_tag :owner, 'Owner'
+ %span= "#{(a)instance.owner.first_name} #{(a)instance.owner.last_name}"
+ %li
+ = label_tag :shared_to, 'Shared to'
+ %span= "N/A"
+ - if @instance.state == Instance::STATE_ERROR
+ %li
+ = label_tag :error, 'Error'
+ %span= @instance.last_error
+
+ = submit_tag 'Back', :name => 'back'
diff --git a/src/app/views/pools/list.haml b/src/app/views/pools/list.haml
index 2014ed9..675891d 100644
--- a/src/app/views/pools/list.haml
+++ b/src/app/views/pools/list.haml
@@ -1,3 +1,3 @@
= render :partial => "instance/instances"
-= link_to "Add a new instance", {:controller => "instance", :action => "new", "instance[pool_id]" => @pool}, :class=>"actionlink"
+= link_to "Add a new instance", {:controller => "instances", :action => "new", "instance[pool_id]" => @pool}, :class=>"actionlink"
diff --git a/src/config/navigation.rb b/src/config/navigation.rb
index fbc4fab..c29b9c9 100644
--- a/src/config/navigation.rb
+++ b/src/config/navigation.rb
@@ -37,7 +37,7 @@ SimpleNavigation::Configuration.run do |navigation|
second_level.item :images, t(:images), '#', :class => 'disabled'
end
first_level.item :runtime, t(:runtime), '#', :class => 'runtime' do |second_level|
- second_level.item :instance_management, t(:instance_management), :controller => 'instance'
+ second_level.item :instance_management, t(:instance_management), :controller => 'instances'
end
first_level.item :help, t(:help), '#', :id => 'help', :class => "disabled"
end
diff --git a/src/config/routes.rb b/src/config/routes.rb
index d736b93..8afbb6a 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -45,7 +45,7 @@ ActionController::Routing::Routes.draw do |map|
map.resources :users
map.dashboard '/dashboard', :controller => 'dashboard'
- map.instance '/instance', :controller => 'instance'
+ map.instance '/instances', :controller => 'instances'
map.templates '/templates', :controller => 'templates'
map.settings '/settings', :controller => 'settings'
map.root :dashboard
diff --git a/src/features/step_definitions/instance.rb b/src/features/step_definitions/instance.rb
index 725f75c..a708fd1 100644
--- a/src/features/step_definitions/instance.rb
+++ b/src/features/step_definitions/instance.rb
@@ -15,17 +15,17 @@ Given /^a mock pending instance exists$/ do
end
Given /^I am viewing the mock instance detail$/ do
- visit url_for :action => 'show', :controller => 'instance',
+ visit url_for :action => 'show', :controller => 'instances',
:id => mock_instance
end
When /^I am viewing the pending instance detail$/ do
- visit url_for :action => 'show', :controller => 'instance',
+ visit url_for :action => 'show', :controller => 'instances',
:id => pending_instance
end
When /^I manually go to the key action for this instance$/ do
- visit url_for :action => 'key', :controller => 'instance',
+ visit url_for :action => 'key', :controller => 'instances',
:id => pending_instance
end
@@ -36,4 +36,4 @@ end
Then /^I should see the Save dialog for a (.+) file$/ do |filetype|
response.headers["Content-Disposition"].should
match(/^attachment;\sfilename=.*#{filetype}$/)
-end
\ No newline at end of file
+end
diff --git a/src/spec/controllers/instance_controller_spec.rb b/src/spec/controllers/instance_controller_spec.rb
index 3df886a..241c05b 100644
--- a/src/spec/controllers/instance_controller_spec.rb
+++ b/src/spec/controllers/instance_controller_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe InstanceController do
+describe InstancesController do
fixtures :all
before(:each) do
@admin_permission = Factory :admin_permission
--
1.7.2.3
13 years, 7 months
[PATCH aggregator] ProviderController renamed to ProvidersController
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
---
src/app/controllers/cloud_accounts_controller.rb | 12 +-
src/app/controllers/provider_controller.rb | 159 --------------------
src/app/controllers/providers_controller.rb | 159 ++++++++++++++++++++
src/app/controllers/templates_controller.rb | 4 +-
src/app/helpers/provider_controller_helper.rb | 23 ---
src/app/views/dashboard/summary.haml | 2 +-
src/app/views/provider/_form.haml | 47 ------
src/app/views/provider/_providers.haml | 13 --
src/app/views/provider/accounts.haml | 125 ---------------
src/app/views/provider/delete.haml | 2 -
src/app/views/provider/edit.haml | 1 -
src/app/views/provider/hardware_profiles.haml | 1 -
src/app/views/provider/index.haml | 1 -
src/app/views/provider/list.haml | 1 -
src/app/views/provider/new.haml | 1 -
src/app/views/provider/realms.haml | 1 -
src/app/views/provider/settings.haml | 3 -
src/app/views/provider/show.haml | 1 -
src/app/views/providers/_form.haml | 47 ++++++
src/app/views/providers/_providers.haml | 13 ++
src/app/views/providers/accounts.haml | 125 +++++++++++++++
src/app/views/providers/delete.haml | 2 +
src/app/views/providers/edit.haml | 1 +
src/app/views/providers/hardware_profiles.haml | 1 +
src/app/views/providers/index.haml | 1 +
src/app/views/providers/list.haml | 1 +
src/app/views/providers/new.haml | 1 +
src/app/views/providers/realms.haml | 1 +
src/app/views/providers/settings.haml | 3 +
src/app/views/providers/show.haml | 1 +
src/app/views/settings/index.haml | 2 +-
src/config/locales/en.yml | 2 +-
src/config/navigation.rb | 6 +-
src/features/support/paths.rb | 8 +-
.../controllers/cloud_accounts_controller_spec.rb | 4 +-
src/spec/controllers/provider_controller_spec.rb | 2 +-
36 files changed, 377 insertions(+), 400 deletions(-)
delete mode 100644 src/app/controllers/provider_controller.rb
create mode 100644 src/app/controllers/providers_controller.rb
delete mode 100644 src/app/helpers/provider_controller_helper.rb
delete mode 100644 src/app/views/provider/_form.haml
delete mode 100644 src/app/views/provider/_providers.haml
delete mode 100644 src/app/views/provider/accounts.haml
delete mode 100644 src/app/views/provider/delete.haml
delete mode 100644 src/app/views/provider/edit.haml
delete mode 100644 src/app/views/provider/hardware_profiles.haml
delete mode 100644 src/app/views/provider/index.haml
delete mode 100644 src/app/views/provider/list.haml
delete mode 100644 src/app/views/provider/new.haml
delete mode 100644 src/app/views/provider/realms.haml
delete mode 100644 src/app/views/provider/settings.haml
delete mode 100644 src/app/views/provider/show.haml
create mode 100644 src/app/views/providers/_form.haml
create mode 100644 src/app/views/providers/_providers.haml
create mode 100644 src/app/views/providers/accounts.haml
create mode 100644 src/app/views/providers/delete.haml
create mode 100644 src/app/views/providers/edit.haml
create mode 100644 src/app/views/providers/hardware_profiles.haml
create mode 100644 src/app/views/providers/index.haml
create mode 100644 src/app/views/providers/list.haml
create mode 100644 src/app/views/providers/new.haml
create mode 100644 src/app/views/providers/realms.haml
create mode 100644 src/app/views/providers/settings.haml
create mode 100644 src/app/views/providers/show.haml
diff --git a/src/app/controllers/cloud_accounts_controller.rb b/src/app/controllers/cloud_accounts_controller.rb
index c9a0c67..e1c9b23 100644
--- a/src/app/controllers/cloud_accounts_controller.rb
+++ b/src/app/controllers/cloud_accounts_controller.rb
@@ -43,7 +43,7 @@ class CloudAccountsController < ApplicationController
if params[:test_account]
test_account(@cloud_account)
- redirect_to :controller => "provider", :action => "accounts", :id => @provider, :cloud_account => params[:cloud_account]
+ redirect_to :controller => "providers", :action => "accounts", :id => @provider, :cloud_account => params[:cloud_account]
elsif @cloud_account.valid?
quota = Quota.new
quota.maximum_running_instances = quota_from_string(params[:quota][:maximum_running_instances])
@@ -54,7 +54,7 @@ class CloudAccountsController < ApplicationController
if request.post? && @cloud_account.save && @cloud_account.populate_realms
flash[:notice] = "Provider account added."
end
- redirect_to :controller => "provider", :action => "accounts", :id => @provider
+ redirect_to :controller => "providers", :action => "accounts", :id => @provider
kick_condor
else
if not @cloud_account.valid_credentials?
@@ -64,7 +64,7 @@ class CloudAccountsController < ApplicationController
else
flash[:notice] = "You must fill in all the required fields"
end
- redirect_to :controller => "provider", :action => "accounts", :id => @provider, :cloud_account => params[:cloud_account]
+ redirect_to :controller => "providers", :action => "accounts", :id => @provider, :cloud_account => params[:cloud_account]
end
end
@@ -111,7 +111,7 @@ class CloudAccountsController < ApplicationController
end
if success
flash[:notice] = "Account updated."
- redirect_to :controller => 'provider', :action => 'accounts', :id => @provider
+ redirect_to :controller => 'providers', :action => 'accounts', :id => @provider
else
flash.now[:notice] = "Error updating the cloud account."
render :template => 'provider/accounts'
@@ -123,7 +123,7 @@ class CloudAccountsController < ApplicationController
require_privilege(Privilege::ACCOUNT_MODIFY,@cloud_account.provider)
if @cloud_account.update_attributes(params[:cloud_account])
flash[:notice] = "Cloud Account updated!"
- redirect_to :controller => 'provider', :action => 'accounts', :id => @cloud_account.provider.id
+ redirect_to :controller => 'providers', :action => 'accounts', :id => @cloud_account.provider.id
else
render :action => :edit
end
@@ -147,7 +147,7 @@ class CloudAccountsController < ApplicationController
else
flash[:notice] = "Cloud Account could not be destroyed"
end
- redirect_to :controller => 'provider', :action => 'accounts', :id => provider.id
+ redirect_to :controller => 'providers', :action => 'accounts', :id => provider.id
end
def test_account(account)
diff --git a/src/app/controllers/provider_controller.rb b/src/app/controllers/provider_controller.rb
deleted file mode 100644
index da5c9bb..0000000
--- a/src/app/controllers/provider_controller.rb
+++ /dev/null
@@ -1,159 +0,0 @@
-#
-# Copyright (C) 2009 Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-# Filters added to this controller apply to all controllers in the application.
-# Likewise, all the methods added will be available for all controllers.
-
-class ProviderController < ApplicationController
- before_filter :require_user
- before_filter :load_providers, :only => [:index, :show, :accounts, :list]
-
- def section_id
- 'administration'
- end
-
- def index
- end
-
- def show
- @provider = Provider.find(:first, :conditions => {:id => params[:id]})
- require_privilege(Privilege::PROVIDER_VIEW, @provider)
- end
-
- def edit
- @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
- @provider = Provider.find(:first, :conditions => {:id => params[:id]})
- require_privilege(Privilege::PROVIDER_MODIFY, @provider)
- render :show
- end
-
- def new
- require_privilege(Privilege::PROVIDER_MODIFY)
- @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
- @provider = Provider.new(params[:provider])
- kick_condor
- render :show
- end
-
- def create
- require_privilege(Privilege::PROVIDER_MODIFY)
- @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
- @provider = Provider.new(params[:provider])
-
- if params[:test_connection]
- test_connection(@provider)
- render :action => "new"
- else
- @provider.set_cloud_type!
- if @provider.save && @provider.populate_hardware_profiles
- flash[:notice] = "Provider added."
- redirect_to :action => "show", :id => @provider
- else
- flash[:notice] = "Cannot add the provider."
- render :action => "new"
- end
- kick_condor
- end
- end
-
- def update
- require_privilege(Privilege::PROVIDER_MODIFY)
- @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
- @provider = Provider.find(:first, :conditions => {:id => params[:provider][:id]})
- previous_cloud_type = @provider.cloud_type
-
- @provider.update_attributes(params[:provider])
- if params[:test_connection]
- test_connection(@provider)
- render :action => "edit"
- else
- @provider.set_cloud_type!
- if previous_cloud_type != @provider.cloud_type
- @provider.errors.add :url, "points to a different provider"
- end
-
- if @provider.errors.empty? and @provider.save
- flash[:notice] = "Provider updated."
- redirect_to :action => "show", :id => @provider
- else
- flash[:notice] = "Cannot update the provider."
- render :action => "edit"
- end
- kick_condor
- end
- end
-
- def destroy
- if request.post?
- @provider = Provider.find(params[:provider][:id])
- require_privilege(Privilege::PROVIDER_MODIFY, p)
- if @provider.destroy and @provider.destroyed?
- redirect_to :action => "index"
- else
- flash[:error] = {
- :summary => "Failed to delete Provider",
- :failures => @provider.errors.full_messages,
- }
- render :action => 'show'
- end
- end
- end
-
- def hardware_profiles
- @provider = Provider.find(params[:id])
- @hardware_profiles = @provider.hardware_profiles
- require_privilege(Privilege::PROVIDER_VIEW, @provider)
- end
-
- def accounts
- @provider = Provider.find(:first, :conditions => {:id => params[:id]})
- require_privilege(Privilege::ACCOUNT_VIEW, @provider)
- if params[:cloud_account]
- @cloud_account = CloudAccount.new(params[:cloud_account])
- @quota = Quota.new(params[:quota])
- end
- end
-
- def realms
- @provider = Provider.find(params[:id])
- @realm_names = @provider.realms.collect { |r| r.name }
- require_privilege(Privilege::PROVIDER_VIEW, @provider)
- end
-
- def settings
- @provider = Provider.find(params[:id])
- end
-
- def list
- end
-
- def test_connection(provider)
- @provider.errors.clear
- if @provider.connect
- flash[:notice] = "Successfuly Connected to Provider"
- else
- flash[:notice] = "Failed to Connect to Provider"
- @provider.errors.add :url
- end
- end
-
- protected
- def load_providers
- @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_VIEW)
- end
-end
diff --git a/src/app/controllers/providers_controller.rb b/src/app/controllers/providers_controller.rb
new file mode 100644
index 0000000..5ea4aee
--- /dev/null
+++ b/src/app/controllers/providers_controller.rb
@@ -0,0 +1,159 @@
+#
+# Copyright (C) 2009 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ProvidersController < ApplicationController
+ before_filter :require_user
+ before_filter :load_providers, :only => [:index, :show, :accounts, :list]
+
+ def section_id
+ 'administration'
+ end
+
+ def index
+ end
+
+ def show
+ @provider = Provider.find(:first, :conditions => {:id => params[:id]})
+ require_privilege(Privilege::PROVIDER_VIEW, @provider)
+ end
+
+ def edit
+ @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
+ @provider = Provider.find(:first, :conditions => {:id => params[:id]})
+ require_privilege(Privilege::PROVIDER_MODIFY, @provider)
+ render :show
+ end
+
+ def new
+ require_privilege(Privilege::PROVIDER_MODIFY)
+ @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
+ @provider = Provider.new(params[:provider])
+ kick_condor
+ render :show
+ end
+
+ def create
+ require_privilege(Privilege::PROVIDER_MODIFY)
+ @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
+ @provider = Provider.new(params[:provider])
+
+ if params[:test_connection]
+ test_connection(@provider)
+ render :action => "new"
+ else
+ @provider.set_cloud_type!
+ if @provider.save && @provider.populate_hardware_profiles
+ flash[:notice] = "Provider added."
+ redirect_to :action => "show", :id => @provider
+ else
+ flash[:notice] = "Cannot add the provider."
+ render :action => "new"
+ end
+ kick_condor
+ end
+ end
+
+ def update
+ require_privilege(Privilege::PROVIDER_MODIFY)
+ @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
+ @provider = Provider.find(:first, :conditions => {:id => params[:provider][:id]})
+ previous_cloud_type = @provider.cloud_type
+
+ @provider.update_attributes(params[:provider])
+ if params[:test_connection]
+ test_connection(@provider)
+ render :action => "edit"
+ else
+ @provider.set_cloud_type!
+ if previous_cloud_type != @provider.cloud_type
+ @provider.errors.add :url, "points to a different provider"
+ end
+
+ if @provider.errors.empty? and @provider.save
+ flash[:notice] = "Provider updated."
+ redirect_to :action => "show", :id => @provider
+ else
+ flash[:notice] = "Cannot update the provider."
+ render :action => "edit"
+ end
+ kick_condor
+ end
+ end
+
+ def destroy
+ if request.post?
+ @provider = Provider.find(params[:provider][:id])
+ require_privilege(Privilege::PROVIDER_MODIFY, p)
+ if @provider.destroy and @provider.destroyed?
+ redirect_to :action => "index"
+ else
+ flash[:error] = {
+ :summary => "Failed to delete Provider",
+ :failures => @provider.errors.full_messages,
+ }
+ render :action => 'show'
+ end
+ end
+ end
+
+ def hardware_profiles
+ @provider = Provider.find(params[:id])
+ @hardware_profiles = @provider.hardware_profiles
+ require_privilege(Privilege::PROVIDER_VIEW, @provider)
+ end
+
+ def accounts
+ @provider = Provider.find(:first, :conditions => {:id => params[:id]})
+ require_privilege(Privilege::ACCOUNT_VIEW, @provider)
+ if params[:cloud_account]
+ @cloud_account = CloudAccount.new(params[:cloud_account])
+ @quota = Quota.new(params[:quota])
+ end
+ end
+
+ def realms
+ @provider = Provider.find(params[:id])
+ @realm_names = @provider.realms.collect { |r| r.name }
+ require_privilege(Privilege::PROVIDER_VIEW, @provider)
+ end
+
+ def settings
+ @provider = Provider.find(params[:id])
+ end
+
+ def list
+ end
+
+ def test_connection(provider)
+ @provider.errors.clear
+ if @provider.connect
+ flash[:notice] = "Successfuly Connected to Provider"
+ else
+ flash[:notice] = "Failed to Connect to Provider"
+ @provider.errors.add :url
+ end
+ end
+
+ protected
+ def load_providers
+ @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_VIEW)
+ end
+end
diff --git a/src/app/controllers/templates_controller.rb b/src/app/controllers/templates_controller.rb
index 55e41c9..12df295 100644
--- a/src/app/controllers/templates_controller.rb
+++ b/src/app/controllers/templates_controller.rb
@@ -194,12 +194,12 @@ class TemplatesController < ApplicationController
# account exists
unless provider = Provider.find_by_cloud_type(target)
flash_error("There is no provider of '#{target}' type, you can add provider \
-on <a href=\"#{url_for :controller => 'provider'}\">the providers page.</a>")
+on <a href=\"#{url_for :controller => 'providers'}\">the providers page.</a>")
render :action => 'build_form' and return
end
if provider.cloud_accounts.empty?
flash_error("There is no provider account for '#{target}' provider, you can \
-add account on <a href=\"#{url_for :controller => 'provider', \
+add account on <a href=\"#{url_for :controller => 'providers', \
:action => 'accounts', :id => provider.id}\">the provider accounts page</a>")
render :action => 'build_form' and return
end
diff --git a/src/app/helpers/provider_controller_helper.rb b/src/app/helpers/provider_controller_helper.rb
deleted file mode 100644
index 46378ed..0000000
--- a/src/app/helpers/provider_controller_helper.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Copyright (C) 2009 Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-# Filters added to this controller apply to all controllers in the application.
-# Likewise, all the methods added will be available for all controllers.
-
-module ProviderControllerHelper
-end
diff --git a/src/app/views/dashboard/summary.haml b/src/app/views/dashboard/summary.haml
index 5eb49a5..e6ba2dd 100644
--- a/src/app/views/dashboard/summary.haml
+++ b/src/app/views/dashboard/summary.haml
@@ -31,7 +31,7 @@
%h2
Actions
- if @is_admin
- %a{:href => url_for(:controller => "provider", :action => "new")}
+ %a{:href => url_for(:controller => "providers", :action => "new")}
Add a Provider
%a{:href => url_for(:controller => "users", :action => "new")}
Create a User
diff --git a/src/app/views/provider/_form.haml b/src/app/views/provider/_form.haml
deleted file mode 100644
index 14cd292..0000000
--- a/src/app/views/provider/_form.haml
+++ /dev/null
@@ -1,47 +0,0 @@
-- readonly = controller.action_name == 'show' ? true : false
-- new_provider = ['new', 'create'].include? controller.action_name
-- edit_provider = ['edit', 'update'].include? controller.action_name
-= render :partial => 'providers'
-#details.grid_13
- %nav.subsubnav
- = render_navigation(:level => 4)
- - if new_provider
- - form_action = 'create'
- - elsif edit_provider
- - form_action = 'update'
- - form_for @provider, :url => {:controller => :provider, :action => form_action}, :class => "dcloud_form" do |f|
- %fieldset
- %label.grid_4.alpha.big{ :for => "provider_name" }
- = t('.provider_name')
- - unless readonly
- %span.required
- *
- %label.grid_5.big{ :for => "provider_url" }
- = t('.provider_url')
- - unless readonly
- %span.required
- *
- %div.grid_4.omega
- = f.error_message_on :url, 'URL '
- = f.error_message_on :name, 'Name '
- = f.text_field :name, :title => t('.provider_name'), :value => (@provider.name if @provider), :disabled => ('disabled' if readonly), :class => "clear grid_4 alpha"
- = f.text_field :url, :title => t('.provider_url'), :class => 'emailinput', :value => (@provider.url if @provider), :disabled => ('disabled' if readonly), :class => "grid_5"
- - if edit_provider:
- = f.hidden_field :id, :value => @provider.id
- .clear.prefix_4.grid_5.suffix_4.alpha.omega
- - if new_provider or edit_provider
- %span
- (
- %button.linkbutton.nospace{ :type => 'submit', :value => t('.test_connection'), :name => 'test_connection', :id => 'test_connection' }<>
- = t('.test_connection')
- )
- - unless readonly
- %p.requirement
- %span.required
- *
- \-
- = t('.required_field')
- - if edit_provider
- %input{ :type => 'submit', :value => t(:save), :name => 'save_provider', :id => 'save_provider' }
- - elsif new_provider
- %input{ :type => 'submit', :value => t(:add), :name => 'add_provider', :id => 'add_provider' }
diff --git a/src/app/views/provider/_providers.haml b/src/app/views/provider/_providers.haml
deleted file mode 100644
index f051692..0000000
--- a/src/app/views/provider/_providers.haml
+++ /dev/null
@@ -1,13 +0,0 @@
-#providers_nav.grid_3.actionsidebar
- %dl
- %dt
- = t('provider.providers')
- - @providers.each do |provider|
- %dd
- - selected = 'selected' if @provider and (provider.id == @provider.id)
- %a{ :href => url_for(:controller => 'provider', :action => 'show', :id => provider), :class => selected }
- = provider.name
- - form_tag({:controller => 'provider', :action => 'edit', :id => @provider}, {:method => :post , :class => 'buttononly'}) do
- = submit_tag t(:edit), :disabled => ('disabled' unless @provider and ['show', 'accounts'].include? controller.action_name)
- - form_tag({:controller => 'provider', :action => 'new'}, {:method => :get , :class => 'buttononly'}) do
- %input{ :type => 'submit', :value => t(:add), :disabled => ('disabled' unless @providers.length == 0) }
diff --git a/src/app/views/provider/accounts.haml b/src/app/views/provider/accounts.haml
deleted file mode 100644
index e555717..0000000
--- a/src/app/views/provider/accounts.haml
+++ /dev/null
@@ -1,125 +0,0 @@
-:javascript
- function set_unlimited_quota(elem_id) {
- $("#" + elem_id)[0].value = "unlimited";
- }
-= render :partial => 'provider/providers'
-#details.grid_13
- %nav.subsubnav
- = render_navigation(:level => 4)
-
- %h1
- = t('.provider_accounts')
- - form_tag ({:controller => 'cloud_accounts', :action => 'update_accounts'}), :multipart => true do
- = hidden_field :provider, :id, :value => @provider.id
- - @provider.cloud_accounts.each do |acct|
- %fieldset.clearfix.nomargin
- %label.grid_4.la.alpha
- = t('.account_name')
- %span.required *
- %label.grid_3.la
- = t('.user_name')
- %span.required *
- %label.grid_3.la
- = t('.password')
- %span.required *
- %label.grid_3.la.omega
- = t('.quota_instances')
- %span.required *
- %fieldset.nomargin.clearfix
- - disabled = 'disabled' unless has_account_modify?(@provider)
- - cloud_account_id = "cloud_accounts[#{acct.id}]"
- = text_field cloud_account_id, :label, :title => t('.account_name'), :value => acct.label, :disabled => disabled, :class => "grid_4 alpha"
- = text_field cloud_account_id, :username, :title => t('.user_name'), :value => acct.username, :disabled => disabled, :class => "grid_3"
- = password_field cloud_account_id, :password, :title => t('.password'), :disabled => disabled, :class => "grid_3"
- = error_message_on :maximum_running_instances, 'Maximum Running Instances '
- = text_field "quota[#{acct.id}]", :maximum_running_instances, :title => t('.quota_instances'), :value => (acct.quota.maximum_running_instances.nil? ? "unlimited" : acct.quota.maximum_running_instances), :disabled => disabled, :id => "quota_instances#{acct.id}", :class => "grid_3 omega"
- %fieldset.nomargin.clearfix
- .grid_3.prefix_10.alpha.omega
- (
- %button.linkbutton.nospace{ :type => 'button', :onclick => "set_unlimited_quota(\"quota_instances#{acct.id}\");" }<>
- = t('.unlimited_quota')
- )
- %fieldset.clearfix.nomargin
- %label.grid_4.la.alpha
- = t('.account_number')
- %span.required *
- %label.grid_3.la
- = t('.account_private_cert')
- %span.required *
- %label.grid_3.la
- = t('.account_public_cert')
- %span.required *
- .grid_3.omega
- %fieldset.clearfix
- = text_field cloud_account_id, :account_number, :title => t('.account_number'), :value => acct.account_number, :disabled => disabled, :class => "grid_4 alpha"
- .grid_3
- = file_field cloud_account_id, :x509_cert_priv_file, :title => t('.account_private_cert'), :disabled => disabled
- .grid_3
- = file_field cloud_account_id, :x509_cert_pub_file, :title => t('.account_public_cert'), :disabled => disabled
- - remove_path = url_for :controller => 'cloud_accounts', :action => 'destroy', :id => acct.id if has_account_modify?(@provider) && acct.destroyable?
- .grid_3.omega
- %a.button{ :href => remove_path, :name => "remove_acc_#{acct.id}", :class => "tiny #{'disabled' unless remove_path}" }
- = t(:remove)
- %fieldset.clearfix.gap
- = link_to t(:reset), {:controller => 'provider', :action => 'accounts', :id => @provider.id}, :class => "button dialogbutton" unless @provider.cloud_accounts.empty?
- = submit_tag t(:save), :name => 'update_cloud_accounts', :class => "dialogbutton" unless @provider.cloud_accounts.empty?
-
- %h2
- = t('.new_provider_account')
- - form_tag({:controller => 'cloud_accounts', :action => 'create'}, :multipart => true) do
- = hidden_field :cloud_account, :provider_id, :value => @provider.id
- %fieldset.clearfix.nomargin
- %label.grid_4.la.alpha
- = t('.account_name')
- %span.required *
- %label.grid_3.la
- = t('.user_name')
- %span.required *
- %label.grid_3.la
- = t('.password')
- %span.required *
- %label.grid_3.la.omega
- = t('.quota_instances')
- %span.required *
- %fieldset.nomargin.clearfix
- = text_field :cloud_account, :label, :title => t('.account_name'), :class => "grid_4 alpha"
- = text_field :cloud_account, :username, :title => t('.user_name'), :class => "grid_3"
- = password_field :cloud_account, :password, :title => t('.password'), :class => "grid_3"
- = text_field "quota", :maximum_running_instances, :title => t('.quota_instances'), :value => "unlimited",:id => "quota_instances", :class => "grid_3 omega"
- %fieldset.nomargin.clearfix
- .grid_3.prefix_10.alpha.omega
- (
- %button.linkbutton.nospace{ :type => 'button', :onclick => "set_unlimited_quota(\"quota_instances\");" }<>
- = t('.unlimited_quota')
- )
- %fieldset.clearfix.nomargin
- %label.grid_4.la.alpha
- = t('.account_number')
- %span.required *
- %label.grid_3.la
- = t('.account_private_cert')
- %span.required *
- %label.grid_3.la
- = t('.account_public_cert')
- %span.required *
- .grid_3.omega
- %fieldset.clearfix.nomargin
- = text_field :cloud_account, :account_number, :title => t('.account_number'), :class => "grid_4 alpha"
- .grid_3
- = file_field :cloud_account, :x509_cert_priv_file, :title => t('.account_private_cert')
- .grid_3
- = file_field :cloud_account, :x509_cert_pub_file, :title => t('.account_public_cert')
- - remove_path = url_for :controller => 'cloud_accounts', :action => 'destroy'
- .grid_3.omega
- (
- %button.linkbutton.nospace{ :type => 'submit', :value => t('.test_account'), :name => 'test_account', :id => 'test_account' }<>
- = t('.test_account')
- )
- %fieldset.clearfix
- .grid_13.alpha.omega
- = submit_tag t(:add), :class => "ra nomargin dialogbutton"
- %section
- %p.requirement
- %span.required *
- \-
- = t('.required_field')
diff --git a/src/app/views/provider/delete.haml b/src/app/views/provider/delete.haml
deleted file mode 100644
index 6727d77..0000000
--- a/src/app/views/provider/delete.haml
+++ /dev/null
@@ -1,2 +0,0 @@
-%h1 ProviderController#delete
-%p Find me in app/views/provider_controller/delete.html.erb
diff --git a/src/app/views/provider/edit.haml b/src/app/views/provider/edit.haml
deleted file mode 100644
index c66fabf..0000000
--- a/src/app/views/provider/edit.haml
+++ /dev/null
@@ -1 +0,0 @@
-= render :partial => 'form'
diff --git a/src/app/views/provider/hardware_profiles.haml b/src/app/views/provider/hardware_profiles.haml
deleted file mode 100644
index 96fe378..0000000
--- a/src/app/views/provider/hardware_profiles.haml
+++ /dev/null
@@ -1 +0,0 @@
-= render :partial => 'hardware_profiles/list'
diff --git a/src/app/views/provider/index.haml b/src/app/views/provider/index.haml
deleted file mode 100644
index 9823f42..0000000
--- a/src/app/views/provider/index.haml
+++ /dev/null
@@ -1 +0,0 @@
-= render :partial => 'providers'
diff --git a/src/app/views/provider/list.haml b/src/app/views/provider/list.haml
deleted file mode 100644
index 6e68450..0000000
--- a/src/app/views/provider/list.haml
+++ /dev/null
@@ -1 +0,0 @@
-= render :partial => 'provider/providers'
\ No newline at end of file
diff --git a/src/app/views/provider/new.haml b/src/app/views/provider/new.haml
deleted file mode 100644
index c66fabf..0000000
--- a/src/app/views/provider/new.haml
+++ /dev/null
@@ -1 +0,0 @@
-= render :partial => 'form'
diff --git a/src/app/views/provider/realms.haml b/src/app/views/provider/realms.haml
deleted file mode 100644
index 31f7886..0000000
--- a/src/app/views/provider/realms.haml
+++ /dev/null
@@ -1 +0,0 @@
-= render :partial => 'realms/list'
diff --git a/src/app/views/provider/settings.haml b/src/app/views/provider/settings.haml
deleted file mode 100644
index b4cdc43..0000000
--- a/src/app/views/provider/settings.haml
+++ /dev/null
@@ -1,3 +0,0 @@
-- form_tag({ :action => 'destroy' }, {:onsubmit => "return confirm('Really delete the provider?');"}) do
- = hidden_field :provider, :id
- = submit_tag "Delete Provider", :class => "submit_link"
diff --git a/src/app/views/provider/show.haml b/src/app/views/provider/show.haml
deleted file mode 100644
index c66fabf..0000000
--- a/src/app/views/provider/show.haml
+++ /dev/null
@@ -1 +0,0 @@
-= render :partial => 'form'
diff --git a/src/app/views/providers/_form.haml b/src/app/views/providers/_form.haml
new file mode 100644
index 0000000..94e2ebf
--- /dev/null
+++ b/src/app/views/providers/_form.haml
@@ -0,0 +1,47 @@
+- readonly = controller.action_name == 'show' ? true : false
+- new_provider = ['new', 'create'].include? controller.action_name
+- edit_provider = ['edit', 'update'].include? controller.action_name
+= render :partial => 'providers'
+#details.grid_13
+ %nav.subsubnav
+ = render_navigation(:level => 4)
+ - if new_provider
+ - form_action = 'create'
+ - elsif edit_provider
+ - form_action = 'update'
+ - form_for @provider, :url => {:controller => :providers, :action => form_action}, :class => "dcloud_form" do |f|
+ %fieldset
+ %label.grid_4.alpha.big{ :for => "provider_name" }
+ = t('.provider_name')
+ - unless readonly
+ %span.required
+ *
+ %label.grid_5.big{ :for => "provider_url" }
+ = t('.provider_url')
+ - unless readonly
+ %span.required
+ *
+ %div.grid_4.omega
+ = f.error_message_on :url, 'URL '
+ = f.error_message_on :name, 'Name '
+ = f.text_field :name, :title => t('.provider_name'), :value => (@provider.name if @provider), :disabled => ('disabled' if readonly), :class => "clear grid_4 alpha"
+ = f.text_field :url, :title => t('.provider_url'), :class => 'emailinput', :value => (@provider.url if @provider), :disabled => ('disabled' if readonly), :class => "grid_5"
+ - if edit_provider:
+ = f.hidden_field :id, :value => @provider.id
+ .clear.prefix_4.grid_5.suffix_4.alpha.omega
+ - if new_provider or edit_provider
+ %span
+ (
+ %button.linkbutton.nospace{ :type => 'submit', :value => t('.test_connection'), :name => 'test_connection', :id => 'test_connection' }<>
+ = t('.test_connection')
+ )
+ - unless readonly
+ %p.requirement
+ %span.required
+ *
+ \-
+ = t('.required_field')
+ - if edit_provider
+ %input{ :type => 'submit', :value => t(:save), :name => 'save_provider', :id => 'save_provider' }
+ - elsif new_provider
+ %input{ :type => 'submit', :value => t(:add), :name => 'add_provider', :id => 'add_provider' }
diff --git a/src/app/views/providers/_providers.haml b/src/app/views/providers/_providers.haml
new file mode 100644
index 0000000..b1a9bec
--- /dev/null
+++ b/src/app/views/providers/_providers.haml
@@ -0,0 +1,13 @@
+#providers_nav.grid_3.actionsidebar
+ %dl
+ %dt
+ = t('providers.providers')
+ - @providers.each do |provider|
+ %dd
+ - selected = 'selected' if @provider and (provider.id == @provider.id)
+ %a{ :href => url_for(:controller => 'providers', :action => 'show', :id => provider), :class => selected }
+ = provider.name
+ - form_tag({:controller => 'providers', :action => 'edit', :id => @provider}, {:method => :post , :class => 'buttononly'}) do
+ = submit_tag t(:edit), :disabled => ('disabled' unless @provider and ['show', 'accounts'].include? controller.action_name)
+ - form_tag({:controller => 'providers', :action => 'new'}, {:method => :get , :class => 'buttononly'}) do
+ %input{ :type => 'submit', :value => t(:add), :disabled => ('disabled' unless @providers.length == 0) }
diff --git a/src/app/views/providers/accounts.haml b/src/app/views/providers/accounts.haml
new file mode 100644
index 0000000..f6f9c84
--- /dev/null
+++ b/src/app/views/providers/accounts.haml
@@ -0,0 +1,125 @@
+:javascript
+ function set_unlimited_quota(elem_id) {
+ $("#" + elem_id)[0].value = "unlimited";
+ }
+= render :partial => 'providers/providers'
+#details.grid_13
+ %nav.subsubnav
+ = render_navigation(:level => 4)
+
+ %h1
+ = t('.provider_accounts')
+ - form_tag ({:controller => 'cloud_accounts', :action => 'update_accounts'}), :multipart => true do
+ = hidden_field :provider, :id, :value => @provider.id
+ - @provider.cloud_accounts.each do |acct|
+ %fieldset.clearfix.nomargin
+ %label.grid_4.la.alpha
+ = t('.account_name')
+ %span.required *
+ %label.grid_3.la
+ = t('.user_name')
+ %span.required *
+ %label.grid_3.la
+ = t('.password')
+ %span.required *
+ %label.grid_3.la.omega
+ = t('.quota_instances')
+ %span.required *
+ %fieldset.nomargin.clearfix
+ - disabled = 'disabled' unless has_account_modify?(@provider)
+ - cloud_account_id = "cloud_accounts[#{acct.id}]"
+ = text_field cloud_account_id, :label, :title => t('.account_name'), :value => acct.label, :disabled => disabled, :class => "grid_4 alpha"
+ = text_field cloud_account_id, :username, :title => t('.user_name'), :value => acct.username, :disabled => disabled, :class => "grid_3"
+ = password_field cloud_account_id, :password, :title => t('.password'), :disabled => disabled, :class => "grid_3"
+ = error_message_on :maximum_running_instances, 'Maximum Running Instances '
+ = text_field "quota[#{acct.id}]", :maximum_running_instances, :title => t('.quota_instances'), :value => (acct.quota.maximum_running_instances.nil? ? "unlimited" : acct.quota.maximum_running_instances), :disabled => disabled, :id => "quota_instances#{acct.id}", :class => "grid_3 omega"
+ %fieldset.nomargin.clearfix
+ .grid_3.prefix_10.alpha.omega
+ (
+ %button.linkbutton.nospace{ :type => 'button', :onclick => "set_unlimited_quota(\"quota_instances#{acct.id}\");" }<>
+ = t('.unlimited_quota')
+ )
+ %fieldset.clearfix.nomargin
+ %label.grid_4.la.alpha
+ = t('.account_number')
+ %span.required *
+ %label.grid_3.la
+ = t('.account_private_cert')
+ %span.required *
+ %label.grid_3.la
+ = t('.account_public_cert')
+ %span.required *
+ .grid_3.omega
+ %fieldset.clearfix
+ = text_field cloud_account_id, :account_number, :title => t('.account_number'), :value => acct.account_number, :disabled => disabled, :class => "grid_4 alpha"
+ .grid_3
+ = file_field cloud_account_id, :x509_cert_priv_file, :title => t('.account_private_cert'), :disabled => disabled
+ .grid_3
+ = file_field cloud_account_id, :x509_cert_pub_file, :title => t('.account_public_cert'), :disabled => disabled
+ - remove_path = url_for :controller => 'cloud_accounts', :action => 'destroy', :id => acct.id if has_account_modify?(@provider) && acct.destroyable?
+ .grid_3.omega
+ %a.button{ :href => remove_path, :name => "remove_acc_#{acct.id}", :class => "tiny #{'disabled' unless remove_path}" }
+ = t(:remove)
+ %fieldset.clearfix.gap
+ = link_to t(:reset), {:controller => 'provider', :action => 'accounts', :id => @provider.id}, :class => "button dialogbutton" unless @provider.cloud_accounts.empty?
+ = submit_tag t(:save), :name => 'update_cloud_accounts', :class => "dialogbutton" unless @provider.cloud_accounts.empty?
+
+ %h2
+ = t('.new_provider_account')
+ - form_tag({:controller => 'cloud_accounts', :action => 'create'}, :multipart => true) do
+ = hidden_field :cloud_account, :provider_id, :value => @provider.id
+ %fieldset.clearfix.nomargin
+ %label.grid_4.la.alpha
+ = t('.account_name')
+ %span.required *
+ %label.grid_3.la
+ = t('.user_name')
+ %span.required *
+ %label.grid_3.la
+ = t('.password')
+ %span.required *
+ %label.grid_3.la.omega
+ = t('.quota_instances')
+ %span.required *
+ %fieldset.nomargin.clearfix
+ = text_field :cloud_account, :label, :title => t('.account_name'), :class => "grid_4 alpha"
+ = text_field :cloud_account, :username, :title => t('.user_name'), :class => "grid_3"
+ = password_field :cloud_account, :password, :title => t('.password'), :class => "grid_3"
+ = text_field "quota", :maximum_running_instances, :title => t('.quota_instances'), :value => "unlimited",:id => "quota_instances", :class => "grid_3 omega"
+ %fieldset.nomargin.clearfix
+ .grid_3.prefix_10.alpha.omega
+ (
+ %button.linkbutton.nospace{ :type => 'button', :onclick => "set_unlimited_quota(\"quota_instances\");" }<>
+ = t('.unlimited_quota')
+ )
+ %fieldset.clearfix.nomargin
+ %label.grid_4.la.alpha
+ = t('.account_number')
+ %span.required *
+ %label.grid_3.la
+ = t('.account_private_cert')
+ %span.required *
+ %label.grid_3.la
+ = t('.account_public_cert')
+ %span.required *
+ .grid_3.omega
+ %fieldset.clearfix.nomargin
+ = text_field :cloud_account, :account_number, :title => t('.account_number'), :class => "grid_4 alpha"
+ .grid_3
+ = file_field :cloud_account, :x509_cert_priv_file, :title => t('.account_private_cert')
+ .grid_3
+ = file_field :cloud_account, :x509_cert_pub_file, :title => t('.account_public_cert')
+ - remove_path = url_for :controller => 'cloud_accounts', :action => 'destroy'
+ .grid_3.omega
+ (
+ %button.linkbutton.nospace{ :type => 'submit', :value => t('.test_account'), :name => 'test_account', :id => 'test_account' }<>
+ = t('.test_account')
+ )
+ %fieldset.clearfix
+ .grid_13.alpha.omega
+ = submit_tag t(:add), :class => "ra nomargin dialogbutton"
+ %section
+ %p.requirement
+ %span.required *
+ \-
+ = t('.required_field')
diff --git a/src/app/views/providers/delete.haml b/src/app/views/providers/delete.haml
new file mode 100644
index 0000000..6727d77
--- /dev/null
+++ b/src/app/views/providers/delete.haml
@@ -0,0 +1,2 @@
+%h1 ProviderController#delete
+%p Find me in app/views/provider_controller/delete.html.erb
diff --git a/src/app/views/providers/edit.haml b/src/app/views/providers/edit.haml
new file mode 100644
index 0000000..c66fabf
--- /dev/null
+++ b/src/app/views/providers/edit.haml
@@ -0,0 +1 @@
+= render :partial => 'form'
diff --git a/src/app/views/providers/hardware_profiles.haml b/src/app/views/providers/hardware_profiles.haml
new file mode 100644
index 0000000..96fe378
--- /dev/null
+++ b/src/app/views/providers/hardware_profiles.haml
@@ -0,0 +1 @@
+= render :partial => 'hardware_profiles/list'
diff --git a/src/app/views/providers/index.haml b/src/app/views/providers/index.haml
new file mode 100644
index 0000000..9823f42
--- /dev/null
+++ b/src/app/views/providers/index.haml
@@ -0,0 +1 @@
+= render :partial => 'providers'
diff --git a/src/app/views/providers/list.haml b/src/app/views/providers/list.haml
new file mode 100644
index 0000000..9517a21
--- /dev/null
+++ b/src/app/views/providers/list.haml
@@ -0,0 +1 @@
+= render :partial => 'providers/providers'
diff --git a/src/app/views/providers/new.haml b/src/app/views/providers/new.haml
new file mode 100644
index 0000000..c66fabf
--- /dev/null
+++ b/src/app/views/providers/new.haml
@@ -0,0 +1 @@
+= render :partial => 'form'
diff --git a/src/app/views/providers/realms.haml b/src/app/views/providers/realms.haml
new file mode 100644
index 0000000..31f7886
--- /dev/null
+++ b/src/app/views/providers/realms.haml
@@ -0,0 +1 @@
+= render :partial => 'realms/list'
diff --git a/src/app/views/providers/settings.haml b/src/app/views/providers/settings.haml
new file mode 100644
index 0000000..b4cdc43
--- /dev/null
+++ b/src/app/views/providers/settings.haml
@@ -0,0 +1,3 @@
+- form_tag({ :action => 'destroy' }, {:onsubmit => "return confirm('Really delete the provider?');"}) do
+ = hidden_field :provider, :id
+ = submit_tag "Delete Provider", :class => "submit_link"
diff --git a/src/app/views/providers/show.haml b/src/app/views/providers/show.haml
new file mode 100644
index 0000000..c66fabf
--- /dev/null
+++ b/src/app/views/providers/show.haml
@@ -0,0 +1 @@
+= render :partial => 'form'
diff --git a/src/app/views/settings/index.haml b/src/app/views/settings/index.haml
index 80f0bd6..5963ec4 100644
--- a/src/app/views/settings/index.haml
+++ b/src/app/views/settings/index.haml
@@ -5,7 +5,7 @@
= t('.manage_providers')
%p
= t('.manage_providers_desc')
- = link_to t(:continue), {:controller => 'provider'}, :class => 'button'
+ = link_to t(:continue), {:controller => 'providers'}, :class => 'button'
%li#users.grid_8
= image_tag "blnk.png", :class => "icon", :alt => ""
%h2
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 0d8cc39..6539cbd 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -87,7 +87,7 @@ en:
self_service_default: 'User Treatment: Self-service default'
quota: Quota
account: Account
- provider:
+ providers:
providers: PROVIDERS
form:
provider_name: Provider Name
diff --git a/src/config/navigation.rb b/src/config/navigation.rb
index c29b9c9..caa864b 100644
--- a/src/config/navigation.rb
+++ b/src/config/navigation.rb
@@ -7,9 +7,9 @@ SimpleNavigation::Configuration.run do |navigation|
end
first_level.item :administration, t(:administration), '#', :class => 'administration' do |second_level|
second_level.item :system_settings, t(:system_settings), :controller => 'settings' do |third_level|
- third_level.item :manage_providers, t(:manage_providers), :controller => 'provider' do |fourth_level|
- fourth_level.item :provider_summary, t(:provider_summary), { :controller => 'provider', :action => 'show', :id => (@provider.id if @provider) }, :highlights_on => /\/provider\/(show|edit)/
- fourth_level.item :provider_accounts, t(:provider_accounts), { :controller => 'provider', :action => 'accounts', :id => (@provider.id if @provider) }, :highlights_on => /\/provider\/accounts/
+ third_level.item :manage_providers, t(:manage_providers), :controller => 'providers' do |fourth_level|
+ fourth_level.item :provider_summary, t(:provider_summary), { :controller => 'providers', :action => 'show', :id => (@provider.id if @provider) }, :highlights_on => /\/providers\/(show|edit)/
+ fourth_level.item :provider_accounts, t(:provider_accounts), { :controller => 'providers', :action => 'accounts', :id => (@provider.id if @provider) }, :highlights_on => /\/providers\/accounts/
fourth_level.item :scheduling_policies, t(:scheduling_policies), '#'
fourth_level.item :services_provided, t(:services_provided), '#'
fourth_level.item :map_profiles, t(:map_profiles), '#'
diff --git a/src/features/support/paths.rb b/src/features/support/paths.rb
index 198099b..e948161 100644
--- a/src/features/support/paths.rb
+++ b/src/features/support/paths.rb
@@ -27,16 +27,16 @@ module NavigationHelpers
user_session_path
when /the providers page/
- url_for :controller => 'provider', :action => 'index', :only_path => true
+ url_for :controller => 'providers', :action => 'index', :only_path => true
when /the new provider page/
- url_for :controller => 'provider', :action => 'new', :only_path => true
+ url_for :controller => 'providers', :action => 'new', :only_path => true
when /the show provider page/
- url_for :controller => 'provider', :action => 'show', :only_path => true
+ url_for :controller => 'providers', :action => 'show', :only_path => true
when /the provider settings page/
- url_for :controller => 'provider', :action => 'settings', :only_path => true
+ url_for :controller => 'providers', :action => 'settings', :only_path => true
when /the settings page/
settings_path
diff --git a/src/spec/controllers/cloud_accounts_controller_spec.rb b/src/spec/controllers/cloud_accounts_controller_spec.rb
index 7a82a7a..f3b866a 100644
--- a/src/spec/controllers/cloud_accounts_controller_spec.rb
+++ b/src/spec/controllers/cloud_accounts_controller_spec.rb
@@ -29,7 +29,7 @@ describe CloudAccountsController do
@cloud_account.save
post :update, :cloud_account => { :id => @cloud_account.id, :password => 'mockpassword' }
- response.should redirect_to("http://test.host/provider/accounts/#{@provider.id}")
+ response.should redirect_to("http://test.host/providers/accounts/#{@provider.id}")
CloudAccount.find((a)cloud_account.id).password.should == "mockpassword"
end
@@ -38,7 +38,7 @@ describe CloudAccountsController do
lambda do
post :destroy, :id => @cloud_account.id
end.should change(CloudAccount, :count).by(-1)
- response.should redirect_to("http://test.host/provider/accounts/#{@provider.id}")
+ response.should redirect_to("http://test.host/providers/accounts/#{@provider.id}")
CloudAccount.find(:first, :conditions => ['id = ?', @cloud_account.id]).should be_nil
end
diff --git a/src/spec/controllers/provider_controller_spec.rb b/src/spec/controllers/provider_controller_spec.rb
index 096af3d..a1a317a 100644
--- a/src/spec/controllers/provider_controller_spec.rb
+++ b/src/spec/controllers/provider_controller_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe ProviderController do
+describe ProvidersController do
fixtures :all
before(:each) do
--
1.7.2.3
13 years, 7 months
[PATCH aeolus] BZ#649389/BZ#652719 Updated Login failed message and removed fields errors on login page
by Martyn Taylor
From: Martyn Taylor <mtaylor(a)redhat.com>
---
src/app/controllers/user_sessions_controller.rb | 1 +
src/app/models/user_session.rb | 2 +-
src/app/views/user_sessions/new.haml | 1 -
src/features/authentication.feature | 11 +++++++++--
src/features/step_definitions/authentication.rb | 4 ++++
5 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/app/controllers/user_sessions_controller.rb b/src/app/controllers/user_sessions_controller.rb
index 14d32ae..3e4e8f0 100644
--- a/src/app/controllers/user_sessions_controller.rb
+++ b/src/app/controllers/user_sessions_controller.rb
@@ -37,6 +37,7 @@ class UserSessionsController < ApplicationController
flash[:notice] = "Login successful!"
redirect_back_or_default root_url
else
+ flash[:warning] = "Login failed: The Username and Password you entered do not match"
render :action => :new
end
end
diff --git a/src/app/models/user_session.rb b/src/app/models/user_session.rb
index b9b2224..544ec6b 100644
--- a/src/app/models/user_session.rb
+++ b/src/app/models/user_session.rb
@@ -20,5 +20,5 @@
# Likewise, all the methods added will be available for all controllers.
class UserSession < Authlogic::Session::Base
-
+ generalize_credentials_error_messages true
end
diff --git a/src/app/views/user_sessions/new.haml b/src/app/views/user_sessions/new.haml
index c3a60f1..9bd71f6 100644
--- a/src/app/views/user_sessions/new.haml
+++ b/src/app/views/user_sessions/new.haml
@@ -2,7 +2,6 @@
%h2 Log In
.dcloud_form
- form_for @user_session, :url => user_session_path do |f|
- = f.error_messages
%fieldset
= f.label :login, "Username:"
= f.text_field :login
diff --git a/src/features/authentication.feature b/src/features/authentication.feature
index 8b94a55..0aa39fd 100644
--- a/src/features/authentication.feature
+++ b/src/features/authentication.feature
@@ -45,7 +45,7 @@ Feature: User authentication
Given I am a registered user
And I am on the login page
When I forget to enter my password
- Then I should see "Password cannot be blank"
+ Then I should see "Login failed"
And I should be on the login error page
Scenario: Edit profile
@@ -74,4 +74,11 @@ Feature: User authentication
Then should see "Editing Account"
When I enter a string of length "101" into "user[login]"
And I press "Save"
- Then I should see "Login is too long (maximum is 100 characters)"
\ No newline at end of file
+ Then I should see "Login is too long (maximum is 100 characters)"
+
+ Scenario: Log in incorrect details
+ Given I am a registered user
+ And I am on the login page
+ When I login with incorrect credentials
+ Then I should see "Login failed"
+ And I should be on the login error page
\ No newline at end of file
diff --git a/src/features/step_definitions/authentication.rb b/src/features/step_definitions/authentication.rb
index 13bc9a6..e7a84bd 100644
--- a/src/features/step_definitions/authentication.rb
+++ b/src/features/step_definitions/authentication.rb
@@ -53,4 +53,8 @@ When /^I enter a string of length "([^"]*)" into "([^"]*)"$/ do |length, field_n
string = ""
length.to_i.times { string << valid_chars[rand(valid_chars.length)] }
When "I fill in \"#{field_name}\" with \"#{string}\""
+end
+
+When /^I login with incorrect credentials$/ do
+ login("wrong_username", "wrong_password")
end
\ No newline at end of file
--
1.7.2.3
13 years, 7 months
[PATCH aggregator] Remove gnuplot and scruffy deps from spec and environment.rb
by Steve Linabery
Since we don't use these now and will be switching to other charting libs (even if this just means our own fork of scruffy) when the time comes.
Revised to include edits to config/environment.rb
---
deltacloud-aggregator.spec.in | 3 -
src/app/services/graph_service.rb | 161 +------------------------------------
src/config/environment.rb | 2 -
3 files changed, 2 insertions(+), 164 deletions(-)
diff --git a/deltacloud-aggregator.spec.in b/deltacloud-aggregator.spec.in
index f05646f..841d135 100644
--- a/deltacloud-aggregator.spec.in
+++ b/deltacloud-aggregator.spec.in
@@ -22,8 +22,6 @@ Requires: rubygem(will_paginate)
Requires: rubygem(parseconfig)
Requires: rubygem(authlogic)
Requires: rubygem(deltacloud-client) >= 0.0.9.8
-Requires: rubygem(gnuplot)
-Requires: rubygem(scruffy)
Requires: rubygem(compass)
Requires: rubygem(compass-960-plugin)
Requires: rubygem(simple-navigation)
@@ -36,7 +34,6 @@ Requires: rubygem(imagebuilder-console)
Requires: postgresql
Requires: postgresql-server
Requires: ruby-postgres
-Requires: gnuplot >= 4.2.6
Requires: ruby-RMagick
Requires: classads >= 1.0
Requires: condor >= 7.5.4
diff --git a/src/app/services/graph_service.rb b/src/app/services/graph_service.rb
index 6c17743..7266434 100644
--- a/src/app/services/graph_service.rb
+++ b/src/app/services/graph_service.rb
@@ -1,7 +1,6 @@
class GraphService
- require 'gnuplot'
+
require 'nokogiri'
- require 'scruffy'
DATA_SERVICE = DataServiceActiveRecord
@@ -64,10 +63,6 @@ class GraphService
end
private
- def self.gnuplot_open( persist=false )
- cmd = Gnuplot.gnuplot( persist ) or raise 'gnuplot not found'
- output_stream = IO::popen( cmd, "r+")
- end
def self.quota_usage_graph (parent, opts = {})
x = [1,2]
@@ -175,39 +170,6 @@ class GraphService
width = 300 unless opts[:width].nil? ? nil : width = opts[:width].to_i
graph = Graph.new
-
- mytheme = Scruffy::Themes::Keynote.new
- mytheme.background = :white
- mytheme.marker = :black #sets the label text color
- mytheme.colors = %w(#00689a #00b0e0)
-
- scruffy_graph = Scruffy::Graph.new({:theme => mytheme})
- scruffy_graph.renderer = Scruffy::Renderers::Pie.new
- scruffy_graph.add :pie, '', pie_opts
-
- raw_svg = scruffy_graph.render :width => width, :height => height
-
- xml = Nokogiri::XML(raw_svg)
- svg = xml.css 'svg'
- svg.each do |node|
- node.set_attribute 'viewBox',"0 0 #{width} #{height}"
- end
-
- xml.root.traverse do |node|
- if node.name == 'text'
- if node.has_attribute? 'font-family'
- node.set_attribute 'font-family','sans-serif'
- end
- if (node.has_attribute? 'font-size') && node.get_attribute('font-size').length > 0
- size = node.get_attribute('font-size').to_f
- size = size * 1.5
- node.set_attribute 'font-size',size.to_s
- end
- end
- end
-
- graph.svg = xml.to_s
- graph
end
def self.draw_line_graph(opts, data)
@@ -217,45 +179,6 @@ class GraphService
width = 100 unless opts[:width].nil? ? nil : width = opts[:width].to_i
graph = Graph.new
- gp = gnuplot_open
-
- Gnuplot::Plot.new( gp ) do |plot|
- plot.terminal "svg size #{width},#{height}"
- plot.arbitrary_lines << "unset xtics"
- plot.arbitrary_lines << "unset x2tics"
- plot.arbitrary_lines << "unset ytics"
- plot.arbitrary_lines << "unset y2tics"
- plot.set "bmargin","0"
- plot.set "lmargin","1"
- plot.set "rmargin","0"
- plot.set "tmargin","0"
-
- #FIXME: get data from DataService for the provider.
- #For demo, plot a random walk for demo of graph display until we hook into DataService
- #First build two equal-length arrays
- #x = (0..500).collect { |v| v.to_f }
-
- #walk = 0
- #y = x.collect { |v| rand > 0.5 ? walk = walk + 1 : walk = walk - 1 }
-
- x = data[:x]
- y = data[:y]
- y_range = data[:y_range]
-
- #plot.set "yrange [-50:50]"
- plot.set "yrange " + y_range
-
- #This type of plot takes two equal length arrays of numbers as input.
- plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
- ds.using = "1:2"
- ds.with = "lines"
- ds.notitle
- end
- end
- gp.flush
- gp.close_write
- gp.read(nil,graph.svg)
- gp.close_read
graph
end
@@ -269,87 +192,7 @@ class GraphService
height = 80 unless opts[:height].nil? ? nil : height = opts[:height].to_i
width = 150 unless opts[:width].nil? ? nil : width = opts[:width].to_i
- raw_svg = ""
- gp = gnuplot_open
- Gnuplot::Plot.new( gp ) do |plot|
- plot.terminal "svg size #{width},#{height}"
- plot.arbitrary_lines << "unset xtics"
- plot.arbitrary_lines << "unset x2tics"
- plot.arbitrary_lines << "unset ytics"
- plot.arbitrary_lines << "unset y2tics"
- plot.arbitrary_lines << "unset border"
-
- plot.set "bmargin","0"
- plot.set "lmargin","0"
- plot.set "rmargin","0"
- plot.set "tmargin","0"
- plot.set "boxwidth 0.9"
- plot.set "style fill solid 1.0"
- plot.set "xrange [.25:2.75]"
- plot.set "yrange [0:#{max_value * 1.5}]" #we want to scale maxvalue 50% larger to leave room for label
-
- x = chart_opts[:x]
- y = chart_opts[:y]
-
- #The two arrays above are three columns of data for gnuplot.
- plot.data << Gnuplot::DataSet.new( [[x[0]], [y[0]]] ) do |ds|
- ds.using = "1:2"
- ds.with = 'boxes linecolor rgb "#8cc63f"'
- ds.notitle
- end
-
- #The two arrays above are three columns of data for gnuplot.
- plot.data << Gnuplot::DataSet.new( [[x[1]], [y[1]]] ) do |ds|
- ds.using = "1:2"
- ds.with = 'boxes linecolor rgb "#cccccc"'
- ds.notitle
- end
-
-
- plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
- ds.using = "1:2:2"
- ds.with = "labels left offset 0,.15 rotate"
- ds.notitle
- end
- end
- gp.flush
- gp.close_write
- gp.read(nil,raw_svg)
- gp.close_read
-
- #massage the svg so that the histogram's bars are oriented horizontally
- xml = Nokogiri::XML(raw_svg)
-
- nodes = xml.root.children
- wrapper = Nokogiri::XML::Node.new "g", xml.root
-
- nodes.each do |node|
- node.parent = wrapper if node.name != "desc" && node.name != "defs"
- end
-
- wrapper.parent = xml.root
- wrapper.set_attribute 'transform',"translate(#{width},0) rotate(90) scale(#{height * 1.0 / width},#{width * 1.0/ height})"
-
- text_nodes = []
- xml.root.traverse do |node|
- if node.name == 'text' && node.inner_text.strip =~ /^\d+$/
- if node.parent.name == 'g'
- pparent = node.parent
- text_nodes << pparent
- end
- end
- end
-
- text_nodes.each do |node|
- attr = node.get_attribute 'transform'
- node.remove_attribute 'transform'
- node.set_attribute 'transform',"#{attr} scale (#{height * 1.0 / width},#{width * 1.0/ height})"
- end
-
- modified_svg = xml.to_s
graph = Graph.new
- graph.svg = modified_svg
- graph
end
-end
\ No newline at end of file
+end
diff --git a/src/config/environment.rb b/src/config/environment.rb
index 423f224..7d8ba2c 100644
--- a/src/config/environment.rb
+++ b/src/config/environment.rb
@@ -47,8 +47,6 @@ Rails::Initializer.run do |config|
config.gem "haml"
config.gem "will_paginate"
config.gem "nokogiri", :version => ">= 1.4.0"
- config.gem "gnuplot"
- config.gem "scruffy"
config.gem "compass", :version => ">= 0.10.2"
config.gem "compass-960-plugin", :lib => "ninesixty"
config.gem "simple-navigation"
--
1.7.2.3
13 years, 7 months
[PATCH aggregator] Fixing broken users controller spec
by lmartinc@redhat.com
This patch is bringing the unit tests build back to green state.
I refactored users_controller_spec.rb to be used without factories.
This patch relies on DatabaseClener patch posted also today.
13 years, 7 months
[PATCH aeolus] BZ#641401 Added Ability to Delete Provider
by Martyn Taylor
From: Martyn Taylor <mtaylor(a)redhat.com>
---
src/app/controllers/provider_controller.rb | 27 +++++++++------
src/app/models/provider.rb | 1 +
src/app/views/provider/_providers.haml | 2 +
src/db/test.sqlite3-journal | Bin 0 -> 7736 bytes
src/features/provider.feature | 19 ++++++++++-
src/features/step_definitions/provider_steps.rb | 41 +++++++++++++++++++++-
src/features/support/custom.rb | 12 +++---
src/spec/factories/replicated_image.rb | 5 +++
8 files changed, 87 insertions(+), 20 deletions(-)
create mode 100644 src/db/test.sqlite3-journal
create mode 100644 src/spec/factories/replicated_image.rb
diff --git a/src/app/controllers/provider_controller.rb b/src/app/controllers/provider_controller.rb
index da5c9bb..8d6ff1f 100644
--- a/src/app/controllers/provider_controller.rb
+++ b/src/app/controllers/provider_controller.rb
@@ -99,19 +99,24 @@ class ProviderController < ApplicationController
end
def destroy
- if request.post?
- @provider = Provider.find(params[:provider][:id])
- require_privilege(Privilege::PROVIDER_MODIFY, p)
- if @provider.destroy and @provider.destroyed?
- redirect_to :action => "index"
- else
- flash[:error] = {
- :summary => "Failed to delete Provider",
- :failures => @provider.errors.full_messages,
- }
- render :action => 'show'
+ if request.post? || request.delete?
+ @provider = Provider.find(params[:id])
+ require_privilege(Privilege::PROVIDER_MODIFY, @provider)
+ if @provider.destroyable?
+ if @provider.destroy and @provider.destroyed?
+ redirect_to :action => "index"
+ flash[:notice] = "Provider Deleted"
+ return
+ end
end
+
+ flash[:error] = {
+ :summary => "Failed to delete Provider",
+ :failures => @provider.errors.full_messages,
+ }
+ render :action => 'show'
end
+ render :action => 'show'
end
def hardware_profiles
diff --git a/src/app/models/provider.rb b/src/app/models/provider.rb
index 6ec3cc3..40ad1b5 100644
--- a/src/app/models/provider.rb
+++ b/src/app/models/provider.rb
@@ -126,4 +126,5 @@ class Provider < ActiveRecord::Base
def valid_framework?
connect.nil? ? false : true
end
+
end
diff --git a/src/app/views/provider/_providers.haml b/src/app/views/provider/_providers.haml
index f051692..f4eeef9 100644
--- a/src/app/views/provider/_providers.haml
+++ b/src/app/views/provider/_providers.haml
@@ -11,3 +11,5 @@
= submit_tag t(:edit), :disabled => ('disabled' unless @provider and ['show', 'accounts'].include? controller.action_name)
- form_tag({:controller => 'provider', :action => 'new'}, {:method => :get , :class => 'buttononly'}) do
%input{ :type => 'submit', :value => t(:add), :disabled => ('disabled' unless @providers.length == 0) }
+ - form_tag({:controller => 'provider', :action => 'destroy', :id => @provider}, {:method => :post , :class => 'buttononly'}) do
+ = submit_tag 'delete', :disabled => ('disabled' unless @provider and ['show', 'accounts'].include? controller.action_name)
\ No newline at end of file
diff --git a/src/db/test.sqlite3-journal b/src/db/test.sqlite3-journal
new file mode 100644
index 0000000000000000000000000000000000000000..fa1b22dd162cf2d1ec3691ec9f59d1b861bdc67c
GIT binary patch
literal 7736
zcmeH{!3n@15Co6Jk0B`_f;FUol$HJ=3J1Qnfo1%t>}zLXBG!5P`HkNbv5l*&fR{6Y
zcFlIo?YuGFARq~(_jf!X5fMPZo<Mq_;sN`qDF^{cAU$y40f~qJ0`>&b12-P9pPGUY
ekOa~L9S=xE1Q4(%kRB*_z<z29LO>Fj9{2(N6$j4%
literal 0
HcmV?d00001
diff --git a/src/features/provider.feature b/src/features/provider.feature
index c332667..12047bb 100644
--- a/src/features/provider.feature
+++ b/src/features/provider.feature
@@ -85,4 +85,21 @@ Feature: Manage Providers
And I fill in "cloud_account[password]" with "incorrect_password"
And I fill in "cloud_account[account_number]" with "12345678"
And I press "test_account"
- Then I should see "Test Connection Failed: Invalid Account Details"
\ No newline at end of file
+ Then I should see "Test Connection Failed: Invalid Account Details"
+
+ Scenario: Delete a provider
+ Given I am on the homepage
+ And there is a provider named "provider1"
+ And this provider has 5 replicated images
+ And this provider has 5 hardware profiles
+ And this provider has a realm
+ And this provider has a cloud account
+ When I go to the providers page
+ And I follow "provider1"
+ And I press "delete"
+ Then I should see "Provider Deleted"
+ And there should not exist a provider named "provider1"
+ And there should not be any replicated images
+ And there should not be any hardware profiles
+ And there should not be a cloud account
+ And there should not be a realm
\ No newline at end of file
diff --git a/src/features/step_definitions/provider_steps.rb b/src/features/step_definitions/provider_steps.rb
index e593d43..abc4662 100644
--- a/src/features/step_definitions/provider_steps.rb
+++ b/src/features/step_definitions/provider_steps.rb
@@ -1,7 +1,12 @@
-Given /^there is not a provider named "([^\"]*)"$/ do |name|
+Given /^there should not exist a provider named "([^\"]*)"$/ do |name|
Provider.find_by_name(name).should be_nil
end
+Given /^there is not a provider named "([^"]*)"$/ do |name|
+ provider = Provider.find_by_name(name)
+ if provider then provider.destroy end
+end
+
Given /^there is a provider named "([^\"]*)"$/ do |name|
@provider = Factory(:mock_provider, :name => name)
end
@@ -20,9 +25,41 @@ When /^I delete provider$/ do
click_button "Delete provider"
end
-
Given /^there are these providers:$/ do |table|
table.hashes.each do |hash|
Factory(:mock_provider, :name => hash['name'])
end
end
+
+Given /^this provider has (\d+) replicated images$/ do |number|
+ number.to_i.times { |i| Factory(:replicated_image, :provider => @provider) }
+end
+
+Given /^this provider has (\d+) hardware profiles$/ do |number|
+ number.to_i.times { |i| Factory(:mock_hwp1, :provider => @provider) }
+end
+
+
+Given /^this provider has a realm$/ do
+ Factory(:realm, :provider => @provider)
+end
+
+Given /^this provider has a cloud account$/ do
+ Factory(:mock_cloud_account, :provider => @provider)
+end
+
+Then /^there should not be any replicated images$/ do
+ ReplicatedImage.find(:all, :conditions => { :provider_id => @provider.id} ).size.should == 0
+end
+
+Then /^there should not be any hardware profiles$/ do
+ HardwareProfile.find(:all, :conditions => { :provider_id => @provider.id} ).size.should == 0
+end
+
+Then /^there should not be a cloud account$/ do
+ CloudAccount.find(:all, :conditions => { :provider_id => @provider.id} ).size.should == 0
+end
+
+Then /^there should not be a realm$/ do
+ Realm.find(:all, :conditions => { :provider_id => @provider.id} ).size.should == 0
+end
diff --git a/src/features/support/custom.rb b/src/features/support/custom.rb
index 6e4e1ef..b5440ae 100644
--- a/src/features/support/custom.rb
+++ b/src/features/support/custom.rb
@@ -34,12 +34,12 @@ CloudAccount.class_eval do
def generate_cloud_account_key
end
- def instance_key
- @key = mock('Key', :null_object => true)
- @key.stub!(:pem).and_return("PEM")
- @key.stub!(:id).and_return("1_user")
- @key
- end
+# def instance_key
+# @key = mock('Key', :null_object => true)
+# @key.stub!(:pem).and_return("PEM")
+# @key.stub!(:id).and_return("1_user")
+# @key
+# end
end
RepositoryManager.class_eval do
diff --git a/src/spec/factories/replicated_image.rb b/src/spec/factories/replicated_image.rb
new file mode 100644
index 0000000..f989380
--- /dev/null
+++ b/src/spec/factories/replicated_image.rb
@@ -0,0 +1,5 @@
+Factory.define :replicated_image do |ri|
+ ri.association :image
+ ri.association :provider
+ ri.sequence(:provider_image_key) { |n| "provider_image_key#(n)" }
+end
\ No newline at end of file
--
1.7.2.3
13 years, 7 months
[PATCH aeolus] BZ#643096 Added test for cancel button on new user page
by Martyn Taylor
From: Martyn Taylor <mtaylor(a)redhat.com>
---
src/features/user.feature | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/src/features/user.feature b/src/features/user.feature
index e11dfba..d98282f 100644
--- a/src/features/user.feature
+++ b/src/features/user.feature
@@ -25,3 +25,10 @@ Feature: Manage Users
And I fill in "user[password_confirmation]" with "new password"
And I press "Save"
Then I should see "User updated!"
+
+ Scenario: Administrator cancels the creation of a user account
+ Given I am on the users page
+ When I follow "create"
+ Then I should be on the new user page
+ When I follow "cancel"
+ Then I should be on the users page
--
1.7.2.3
13 years, 7 months
[PATCH aggregator 2/2] ImageController renamed to ImagesController
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
---
src/app/controllers/image_controller.rb | 57 ------------------------------
src/app/controllers/images_controller.rb | 57 ++++++++++++++++++++++++++++++
src/app/helpers/image_helper.rb | 2 -
3 files changed, 57 insertions(+), 59 deletions(-)
delete mode 100644 src/app/controllers/image_controller.rb
create mode 100644 src/app/controllers/images_controller.rb
delete mode 100644 src/app/helpers/image_helper.rb
diff --git a/src/app/controllers/image_controller.rb b/src/app/controllers/image_controller.rb
deleted file mode 100644
index 8cd8cbe..0000000
--- a/src/app/controllers/image_controller.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-# Copyright (C) 2009 Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-# Filters added to this controller apply to all controllers in the application.
-# Likewise, all the methods added will be available for all controllers.
-
-class ImageController < ApplicationController
- before_filter :require_user
-
- def section_id
- 'build'
- end
-
- def index
- end
-
- def cancel
- Image.update(params[:id], :status => Image::STATE_CANCELED)
- redirect_to :controller => 'templates', :action => 'new', :params => {'image_descriptor[id]' => params[:template_id], :tab => 'software'}
- end
-
- def show
- if params[:create_instance]
- redirect_to :controller => 'instances', :action => 'new', 'instance[image_id]' => (params[:ids] || []).first
- end
-
- require_privilege(Privilege::IMAGE_VIEW)
-
- @order_dir = params[:order_dir] == 'desc' ? 'desc' : 'asc'
- @order = params[:order] || 'name'
- @images = Image.search_filter(params[:search], Image::SEARCHABLE_COLUMNS).paginate(
- :page => params[:page] || 1,
- :order => @order + ' ' + @order_dir,
- :include => :instances
- )
-
- if request.xhr? and params[:partial]
- render :partial => 'images'
- return
- end
- end
-end
diff --git a/src/app/controllers/images_controller.rb b/src/app/controllers/images_controller.rb
new file mode 100644
index 0000000..3f8623b
--- /dev/null
+++ b/src/app/controllers/images_controller.rb
@@ -0,0 +1,57 @@
+#
+# Copyright (C) 2009 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ImagesController < ApplicationController
+ before_filter :require_user
+
+ def section_id
+ 'build'
+ end
+
+ def index
+ end
+
+ def cancel
+ Image.update(params[:id], :status => Image::STATE_CANCELED)
+ redirect_to :controller => 'templates', :action => 'new', :params => {'image_descriptor[id]' => params[:template_id], :tab => 'software'}
+ end
+
+ def show
+ if params[:create_instance]
+ redirect_to :controller => 'instances', :action => 'new', 'instance[image_id]' => (params[:ids] || []).first
+ end
+
+ require_privilege(Privilege::IMAGE_VIEW)
+
+ @order_dir = params[:order_dir] == 'desc' ? 'desc' : 'asc'
+ @order = params[:order] || 'name'
+ @images = Image.search_filter(params[:search], Image::SEARCHABLE_COLUMNS).paginate(
+ :page => params[:page] || 1,
+ :order => @order + ' ' + @order_dir,
+ :include => :instances
+ )
+
+ if request.xhr? and params[:partial]
+ render :partial => 'images'
+ return
+ end
+ end
+end
diff --git a/src/app/helpers/image_helper.rb b/src/app/helpers/image_helper.rb
deleted file mode 100644
index b1092d1..0000000
--- a/src/app/helpers/image_helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module ImageHelper
-end
--
1.7.2.3
13 years, 7 months
[PATCH aeolus] BZ#643096 Added test for cancel button on new user page
by Martyn Taylor
From: Martyn Taylor <mtaylor(a)redhat.com>
---
src/features/user.feature | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/src/features/user.feature b/src/features/user.feature
index e11dfba..d98282f 100644
--- a/src/features/user.feature
+++ b/src/features/user.feature
@@ -25,3 +25,10 @@ Feature: Manage Users
And I fill in "user[password_confirmation]" with "new password"
And I press "Save"
Then I should see "User updated!"
+
+ Scenario: Administrator cancels the creation of a user account
+ Given I am on the users page
+ When I follow "create"
+ Then I should be on the new user page
+ When I follow "cancel"
+ Then I should be on the users page
--
1.7.2.3
13 years, 7 months