Fixed Chrome accept headers (rev 4)
by Michal Fojtik
Hi,
Quick hotfix for API bug for Chrome browsers. Chrome want's
application/xhtml+xml, which respond_to plugin recognize as :xhtml
respond format. Unfortunatelly, we don't handle this format but :html.
Next issue is, that Chrome is sending 'application/xml' first,
which break our HTML version of API (always returning XML).
So I fixed both issues in this one patch for Chrome.
-- Michal
13 years, 11 months
[PATCH aggregator] Hook 'Instances By Provider' to Real Data
by Steve Linabery
Also adjust font face and size for pie chart.
Also remove chart title.
---
src/app/services/graph_service.rb | 29 ++++++++++++++++++++++++-----
1 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/src/app/services/graph_service.rb b/src/app/services/graph_service.rb
index 6aa5b5b..5ad51c3 100644
--- a/src/app/services/graph_service.rb
+++ b/src/app/services/graph_service.rb
@@ -214,14 +214,20 @@ class GraphService
mytheme.marker = :black #sets the label text color
scruffy_graph = Scruffy::Graph.new({:theme => mytheme})
- scruffy_graph.title = "Instances by Provider"
scruffy_graph.renderer = Scruffy::Renderers::Pie.new
pie_opts = {}
- #FIXME query Instances table to get this information!
- pie_opts[:"EC2"] = 55
- pie_opts[:"RHEV-M"] = 78
- pie_opts[:other] = 21
+ providers = Provider.all
+ providers.each do |provider|
+ running_instances = 0
+ provider.cloud_accounts.each do |account|
+ running_instances = running_instances + account.quota.running_instances if account.quota
+ end
+ if running_instances > 0
+ pie_opts[:"#{provider.name}"] = running_instances
+ end
+ end
+
scruffy_graph.add :pie, '', pie_opts
@@ -233,6 +239,19 @@ class GraphService
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
--
1.6.6.1
13 years, 11 months
[PATCH aggregator] Added Key to Quota utilization by account graph & Fix aligning on Quota Utilization Graphs
by Martyn Taylor
From: martyntaylor <mtaylor(a)redhat.com>
---
src/app/views/dashboard/summary.haml | 5 +++++
.../images/quota_usage_key_instances_limit.png | Bin 0 -> 184 bytes
.../images/quota_usage_key_running_instances.png | Bin 0 -> 184 bytes
src/public/stylesheets/components.css | 11 +++++++++++
4 files changed, 16 insertions(+), 0 deletions(-)
create mode 100644 src/public/images/quota_usage_key_instances_limit.png
create mode 100644 src/public/images/quota_usage_key_running_instances.png
diff --git a/src/app/views/dashboard/summary.haml b/src/app/views/dashboard/summary.haml
index d8813a1..0016c7c 100644
--- a/src/app/views/dashboard/summary.haml
+++ b/src/app/views/dashboard/summary.haml
@@ -98,6 +98,11 @@
Quota Usage
.dashboard_section_summary
Instance utilization by account
+ .account_quota_usage_graph_key
+ %img{:src => "images/quota_usage_key_running_instances.png", :width => 10, :heigth => 10}
+ Running
+ %img{:src => "images/quota_usage_key_instances_limit.png", :width => 10, :heigth => 10}
+ Limit
- @cloud_accounts.each do |account|
.account_quota_usage_graph_summary
= account.provider.name + ": " + account.name
diff --git a/src/public/images/quota_usage_key_instances_limit.png b/src/public/images/quota_usage_key_instances_limit.png
new file mode 100644
index 0000000000000000000000000000000000000000..c8dde6427fcad1da83edf757ff8730c4f842a124
GIT binary patch
literal 184
zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VOR<w@2nP_<aHMnq`J4qFk;Opu
z*Fl)kNn>^eP*AeOHKHUqKdq!Zu_%?Hyu4g5GcUV1Ik6yBFTW^#_B$IXpdwRG7sn8b
z-ejBNXMaT5*x2mYUN!jZ1RP$Gs=zF~l}F07;L3qOW_Mm0QvuNp1_lN-ixySRXZX5>
VE&Y(<87rUx44$rjF6*2UngBrjG93T_
literal 0
HcmV?d00001
diff --git a/src/public/images/quota_usage_key_running_instances.png b/src/public/images/quota_usage_key_running_instances.png
new file mode 100644
index 0000000000000000000000000000000000000000..799f3cb7e055c133e9080cfe8841cdccb8b15a9a
GIT binary patch
literal 184
zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VOR<w@2nP_<aHMnq`J4qFk;Opu
z*Fl)kNn>^eP*AeOHKHUqKdq!Zu_%?Hyu4g5GcUV1Ik6yBFTW^#_B$IXpdwRG7sn8b
z-sCryY5ylQHa5<0w0fY-eZ?S4^27lb-DWpl8PkF*2LhShd0kj_czAf^S7zLEXW({V
VomU|pYzH)e!PC{xWt~$(69A?OG4%id
literal 0
HcmV?d00001
diff --git a/src/public/stylesheets/components.css b/src/public/stylesheets/components.css
index 99fb5d0..9596755 100644
--- a/src/public/stylesheets/components.css
+++ b/src/public/stylesheets/components.css
@@ -243,6 +243,17 @@ ul.nav li:hover {
padding-left: 15px;
display: inline;
float: left;
+ width: 25%
+}
+
+.account_quota_usage_graph_key {
+ float: right;
+ vertical-align: top;
+ font-size: 0.8em;
+ text-align: right;
+ width: 100%;
+ height: 10px;
+ padding: 0 15px 0 0;
}
.account_quota_usage_history_graph {
--
1.6.6.1
13 years, 11 months
[PATCH aggregator] integrate instances by provider into dash
by Mo Morsi
* also couple of small cleanup changes
---
src/app/controllers/dashboard_controller.rb | 13 +++++++++----
src/app/services/graph_service.rb | 1 +
src/app/views/dashboard/summary.haml | 3 ++-
src/public/stylesheets/components.css | 6 ++++++
4 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/src/app/controllers/dashboard_controller.rb b/src/app/controllers/dashboard_controller.rb
index 845901f..bcd2073 100644
--- a/src/app/controllers/dashboard_controller.rb
+++ b/src/app/controllers/dashboard_controller.rb
@@ -31,8 +31,7 @@ class DashboardController < ApplicationController
return params[:ajax] == "true"
end
- def provider_qos_graph(opts = {})
- entity = nil
+ def provider_qos_graph
params[:provider] = Provider.find(params[:id])
graph = GraphService.dashboard_qos(current_user, params)[params[:provider]][Graph::QOS_AVG_TIME_TO_SUBMIT]
respond_to do |format|
@@ -40,8 +39,7 @@ class DashboardController < ApplicationController
end
end
- def account_quota_graph(opts = {})
- entity = nil
+ def account_quota_graph
params[:account] = CloudAccount.find(params[:id])
graph = GraphService.dashboard_quota(current_user, params)[params[:account]][Graph::QUOTA_INSTANCES_IN_USE]
respond_to do |format|
@@ -49,6 +47,13 @@ class DashboardController < ApplicationController
end
end
+ def provider_instances_graph
+ graph = GraphService.dashboard_instances_by_provider(current_user, params)[Graph::INSTANCES_BY_PROVIDER_PIE]
+ respond_to do |format|
+ format.svg { render :xml => graph.svg}
+ end
+ end
+
def index
# FIXME filter to just those that the user has access to
@cloud_accounts = CloudAccount.find(:all)
diff --git a/src/app/services/graph_service.rb b/src/app/services/graph_service.rb
index f56bbfc..6aa5b5b 100644
--- a/src/app/services/graph_service.rb
+++ b/src/app/services/graph_service.rb
@@ -49,6 +49,7 @@ class GraphService
#FIXME add permission checks to see if user can view this graph
graphs = Hash.new
graphs[Graph::INSTANCES_BY_PROVIDER_PIE] = instances_by_provider_pie(opts)
+ graphs
end
private
diff --git a/src/app/views/dashboard/summary.haml b/src/app/views/dashboard/summary.haml
index d8813a1..1fc1923 100644
--- a/src/app/views/dashboard/summary.haml
+++ b/src/app/views/dashboard/summary.haml
@@ -90,7 +90,8 @@
%li
Total instances
.count= @stats[:total_instances]
- .instance_graph
+ #provider_instances_graph
+ %object{ :data => url_for(:action => :provider_instances_graph, :width => 220, :height => 290), :type => 'image/svg+xml'}
.dashboard_column
#quota_usage_dashboard_section
diff --git a/src/public/stylesheets/components.css b/src/public/stylesheets/components.css
index 99fb5d0..48bc77e 100644
--- a/src/public/stylesheets/components.css
+++ b/src/public/stylesheets/components.css
@@ -228,6 +228,12 @@ ul.nav li:hover {
float: left;
}
+#provider_instances_graph {
+ width: 230px;
+ height: 320px;
+ float: left;
+}
+
#quota_usage_dashboard_section {
width: 390px;
border: 1px solid black;
--
1.6.2.5
13 years, 11 months
[PATCH aggregator] integrate instances by provider into dash
by Mo Morsi
* also couple of small cleanup changes
---
src/app/controllers/dashboard_controller.rb | 13 +++++++++----
src/app/services/graph_service.rb | 1 +
src/app/views/dashboard/summary.haml | 3 ++-
src/public/stylesheets/components.css | 6 ++++++
4 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/src/app/controllers/dashboard_controller.rb b/src/app/controllers/dashboard_controller.rb
index 845901f..bcd2073 100644
--- a/src/app/controllers/dashboard_controller.rb
+++ b/src/app/controllers/dashboard_controller.rb
@@ -31,8 +31,7 @@ class DashboardController < ApplicationController
return params[:ajax] == "true"
end
- def provider_qos_graph(opts = {})
- entity = nil
+ def provider_qos_graph
params[:provider] = Provider.find(params[:id])
graph = GraphService.dashboard_qos(current_user, params)[params[:provider]][Graph::QOS_AVG_TIME_TO_SUBMIT]
respond_to do |format|
@@ -40,8 +39,7 @@ class DashboardController < ApplicationController
end
end
- def account_quota_graph(opts = {})
- entity = nil
+ def account_quota_graph
params[:account] = CloudAccount.find(params[:id])
graph = GraphService.dashboard_quota(current_user, params)[params[:account]][Graph::QUOTA_INSTANCES_IN_USE]
respond_to do |format|
@@ -49,6 +47,13 @@ class DashboardController < ApplicationController
end
end
+ def provider_instances_graph
+ graph = GraphService.dashboard_instances_by_provider(current_user, params)[Graph::INSTANCES_BY_PROVIDER_PIE]
+ respond_to do |format|
+ format.svg { render :xml => graph.svg}
+ end
+ end
+
def index
# FIXME filter to just those that the user has access to
@cloud_accounts = CloudAccount.find(:all)
diff --git a/src/app/services/graph_service.rb b/src/app/services/graph_service.rb
index f56bbfc..6aa5b5b 100644
--- a/src/app/services/graph_service.rb
+++ b/src/app/services/graph_service.rb
@@ -49,6 +49,7 @@ class GraphService
#FIXME add permission checks to see if user can view this graph
graphs = Hash.new
graphs[Graph::INSTANCES_BY_PROVIDER_PIE] = instances_by_provider_pie(opts)
+ graphs
end
private
diff --git a/src/app/views/dashboard/summary.haml b/src/app/views/dashboard/summary.haml
index d8813a1..7cb3cb3 100644
--- a/src/app/views/dashboard/summary.haml
+++ b/src/app/views/dashboard/summary.haml
@@ -90,7 +90,8 @@
%li
Total instances
.count= @stats[:total_instances]
- .instance_graph
+ #provider_instances_graph
+ %object{ :data => url_for(:action => :provider_instances_graph, :width => 200, :height => 100), :type => 'image/svg+xml'}
.dashboard_column
#quota_usage_dashboard_section
diff --git a/src/public/stylesheets/components.css b/src/public/stylesheets/components.css
index 99fb5d0..4007228 100644
--- a/src/public/stylesheets/components.css
+++ b/src/public/stylesheets/components.css
@@ -228,6 +228,12 @@ ul.nav li:hover {
float: left;
}
+#provider_instances_graph {
+ width: 200px;
+ height: 250px;
+ float: left;
+}
+
#quota_usage_dashboard_section {
width: 390px;
border: 1px solid black;
--
1.6.2.5
13 years, 11 months
[PATCH aggregator] Fix for permissions error on Dash.
by Jason Guiditta
This happened if you were not a site admin because we do
not have perms hooked directly to instances, but pools.
---
src/app/models/instance.rb | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
index 591bc62..ee35ba5 100644
--- a/src/app/models/instance.rb
+++ b/src/app/models/instance.rb
@@ -171,7 +171,10 @@ class Instance < ActiveRecord::Base
:stopped_instances => 0,
}
- instances = Instance.with_hardware_profile.list_for_user(user, Privilege::INSTANCE_VIEW)
+ instances = []
+ pools = Pool.list_for_user(user, Privilege::INSTANCE_VIEW)
+ pools.each{|pool| pool.instances.each {|i| instances << i}}
+ #instances = Instance.with_hardware_profile.list_for_user(user, Privilege::INSTANCE_VIEW)
instances.each do |i|
if i.state == Instance::STATE_RUNNING
stats[:running_instances] += 1
--
1.6.2.5
13 years, 11 months
[PATCH aggregator] Generate 'Instances By Provider' Pie Chart
by Steve Linabery
This requires 'gem install scruffy', as well as the fedora ruby-RMagick package.
Also fixed a bug introduced by a previous commit where a nil option passed to graph methods
was resulting in setting a default parameter to zero (since nil.to_i -> 0).
---
deltacloud-aggregator.spec.in | 1 +
src/app/models/graph.rb | 1 +
src/app/services/graph_service.rb | 51 ++++++++++++++++++++++++++++++++++---
src/config/environment.rb | 1 +
4 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/deltacloud-aggregator.spec.in b/deltacloud-aggregator.spec.in
index 88ed70e..6baf65e 100644
--- a/deltacloud-aggregator.spec.in
+++ b/deltacloud-aggregator.spec.in
@@ -29,6 +29,7 @@ Requires: postgresql
Requires: postgresql-server
Requires: ruby-postgres
Requires: gnuplot >= 4.2.6
+Requires: ruby-RMagick
%package daemons
Summary: Deltacloud Aggregator daemons config
diff --git a/src/app/models/graph.rb b/src/app/models/graph.rb
index f520a82..1c20dc3 100644
--- a/src/app/models/graph.rb
+++ b/src/app/models/graph.rb
@@ -3,6 +3,7 @@ class Graph
QOS_AVG_TIME_TO_SUBMIT = "qos_avg_time_to_submit"
QUOTA_INSTANCES_IN_USE = "quota_instances_in_use"
+ INSTANCES_BY_PROVIDER_PIE = "instances_by_provider_pie"
def initialize
@svg = ""
end
diff --git a/src/app/services/graph_service.rb b/src/app/services/graph_service.rb
index c2cf4c5..f56bbfc 100644
--- a/src/app/services/graph_service.rb
+++ b/src/app/services/graph_service.rb
@@ -1,6 +1,7 @@
class GraphService
require 'gnuplot'
require 'nokogiri'
+ require 'scruffy'
def self.dashboard_quota (user,opts = {})
#FIXME add permission checks to filter what graphs user can get
@@ -44,6 +45,12 @@ class GraphService
graphs
end
+ def self.dashboard_instances_by_provider (user,opts = {})
+ #FIXME add permission checks to see if user can view this graph
+ graphs = Hash.new
+ graphs[Graph::INSTANCES_BY_PROVIDER_PIE] = instances_by_provider_pie(opts)
+ end
+
private
def self.gnuplot_open( persist=false )
cmd = Gnuplot.gnuplot( persist ) or raise 'gnuplot not found'
@@ -56,8 +63,8 @@ class GraphService
unless max_value = opts[:max_value]
max_value = 100 unless max_value = Quota.maximum('maximum_running_instances')
end
- height = 80 unless height = opts[:height].to_i
- width = 150 unless width = opts[:width].to_i
+ 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 = ""
@@ -153,8 +160,8 @@ class GraphService
def self.qos_avg_time_to_submit_graph (provider, opts = {})
#things we're checking for in opts: :height, :width
- height = 60 unless height = opts[:height].to_i
- width = 100 unless width = opts[:width].to_i
+ height = 60 unless opts[:height].nil? ? nil : height = opts[:height].to_i
+ width = 100 unless opts[:width].nil? ? nil : width = opts[:width].to_i
graph = Graph.new
gp = gnuplot_open
@@ -193,4 +200,40 @@ class GraphService
graph
end
+ def self.instances_by_provider_pie (opts = {})
+ #things we're checking for in opts: :height, :width
+
+ height = 200 unless opts[:height].nil? ? nil : height = opts[:height].to_i
+ 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
+
+ scruffy_graph = Scruffy::Graph.new({:theme => mytheme})
+ scruffy_graph.title = "Instances by Provider"
+ scruffy_graph.renderer = Scruffy::Renderers::Pie.new
+
+ pie_opts = {}
+ #FIXME query Instances table to get this information!
+ pie_opts[:"EC2"] = 55
+ pie_opts[:"RHEV-M"] = 78
+ pie_opts[:other] = 21
+
+ 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
+
+ graph.svg = xml.to_s
+ graph
+ end
+
end
diff --git a/src/config/environment.rb b/src/config/environment.rb
index 53ed761..919a710 100644
--- a/src/config/environment.rb
+++ b/src/config/environment.rb
@@ -48,6 +48,7 @@ Rails::Initializer.run do |config|
config.gem "will_paginate"
config.gem "nokogiri", :version => ">= 1.4.0"
config.gem "gnuplot"
+ config.gem "scruffy"
config.active_record.observers = :instance_observer, :task_observer
# Only load the plugins named here, in the order given. By default, all plugins
--
1.6.6.1
13 years, 11 months
Fix left nav permissions and tweak main menu
by Tomas Sedovic
These two patches address two issues brought up by Jason and Jeremy.
One is that the rigt panel didn't check for the appropriate privileges and the
second is that there was some extraneous whitespace in the main menu text.
These two patches fix them both.
13 years, 11 months
[PATCH aggregator] various fixes
by Mo Morsi
* hide getting started dashboard portlet
* remove key indicators graph placeholder
* remove account quota usage history graph placeholder
* remove quota usage by pool section
* change username in header to user's first/last name
---
src/app/controllers/dashboard_controller.rb | 3 ++-
src/app/views/dashboard/summary.haml | 19 ++-----------------
src/app/views/layouts/_header.haml | 2 +-
3 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/src/app/controllers/dashboard_controller.rb b/src/app/controllers/dashboard_controller.rb
index 6f02c4e..0a3e948 100644
--- a/src/app/controllers/dashboard_controller.rb
+++ b/src/app/controllers/dashboard_controller.rb
@@ -61,7 +61,8 @@ class DashboardController < ApplicationController
@is_admin = @current_user.permissions.collect { |p| p.role }.
find { |r| r.name == "Administrator" }
- @hide_getting_started = cookies["#{(a)current_user.login}_hide_getting_started"]
+ @hide_getting_started = true
+ #@hide_getting_started = cookies["#{(a)current_user.login}_hide_getting_started"]
@current_users_pool = Pool.find(:first, :conditions => ['name = ?', @current_user.login])
@cloud_accounts = CloudAccount.list_for_user(@current_user, Privilege::ACCOUNT_VIEW)
@stats = Instance.get_user_instances_stats(@current_user)
diff --git a/src/app/views/dashboard/summary.haml b/src/app/views/dashboard/summary.haml
index a1fd296..d8813a1 100644
--- a/src/app/views/dashboard/summary.haml
+++ b/src/app/views/dashboard/summary.haml
@@ -90,7 +90,7 @@
%li
Total instances
.count= @stats[:total_instances]
- .instance_graph #instance_graph
+ .instance_graph
.dashboard_column
#quota_usage_dashboard_section
@@ -100,25 +100,10 @@
Instance utilization by account
- @cloud_accounts.each do |account|
.account_quota_usage_graph_summary
- = "Account " + account.username
- .account_quota_usage_history_graph
- <!-- FIXME include graph -->
+ = account.provider.name + ": " + account.name
.account_quota_usage_current_graph
%object{ :data => url_for(:action => :account_quota_graph, :id => account.id, :width => 100, :height => 50), :type => 'image/svg+xml'}
<div style="clear: both;" />
- .dashboard_section_summary
- <img src="images/dashboard_summary_next.png" /><img src="images/dashboard_summary_prev.png" />
- %p
- Quota usage by pool
- <div style="clear: both;" />
- - @pools.each do |pool|
- .pool_quota_usage_summary
- = pool.name
- .pool_quota_usage_limit
- <!-- FIXME 'quota limit met'... -->
- .pool_quota_usage_instances
- <!-- FIXME 'running instances'... -->
- <div style="clear: both;" />
:javascript
$("#hide_getting_started").click(function(){
diff --git a/src/app/views/layouts/_header.haml b/src/app/views/layouts/_header.haml
index 5b38b81..bc76755 100644
--- a/src/app/views/layouts/_header.haml
+++ b/src/app/views/layouts/_header.haml
@@ -11,6 +11,6 @@
.header_info
#hi-username
- = link_to @current_user.login, { :controller => "users", :action => "show"} unless @current_user.nil?
+ = link_to @current_user.first_name + " " + @current_user.last_name, { :controller => "users", :action => "show"} unless @current_user.nil?
= link_to 'Log out', logout_url unless @current_user.nil?
= link_to 'Log in', login_url if @current_user.nil?
--
1.6.2.5
13 years, 11 months
Image Builder Integration
by Jason Guiditta
[PATCH 1/2] Baseline changes needed for image builder integration.
[PATCH 2/2] Add initial integration with Image Builder.
These two patches need a new library that does not yet have a public
repo. I will assist patch reviewer in setting up the needed deps.
13 years, 11 months