[PATCH conductor] Fix overly broad Backbone route matching
by Tomas Sedovic
From: Tomas Sedovic <tsedovic(a)redhat.com>
Our Backbone routes used to match URLs such as /deployments/new to the `show`
action.
Now they match only if the ':id' part of the URL is a number.
---
src/public/javascripts/application.js | 2 +-
src/public/javascripts/backbone/routers.js | 5 +++++
2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/src/public/javascripts/application.js b/src/public/javascripts/application.js
index 11e2413..b74937c 100644
--- a/src/public/javascripts/application.js
+++ b/src/public/javascripts/application.js
@@ -197,7 +197,7 @@ $.extend(Conductor, {
},
idFromURLFragment: function(urlFragment) {
- return urlFragment.split('?')[0];
+ return parseInt(urlFragment.split('?')[0]);
},
saveCheckboxes: function(checkboxSelector, $scope) {
diff --git a/src/public/javascripts/backbone/routers.js b/src/public/javascripts/backbone/routers.js
index ead13ab..46c7f71 100644
--- a/src/public/javascripts/backbone/routers.js
+++ b/src/public/javascripts/backbone/routers.js
@@ -12,6 +12,9 @@ Conductor.Routers.Pools = Backbone.Router.extend({
},
show: function(id) {
+ id = Conductor.idFromURLFragment(id);
+ if(! _.isNumber(id)) return;
+
var pool = new Conductor.Models.Pool({ id: id });
var view = new Conductor.Views.PoolsShow({ model: pool });
pool.bind('change', function() { view.render() });
@@ -32,6 +35,8 @@ Conductor.Routers.Deployments = Backbone.Router.extend({
show: function(id) {
id = Conductor.idFromURLFragment(id);
+ if(! _.isNumber(id)) return;
+
var deployment = new Conductor.Models.Deployment({ id: id });
var view = new Conductor.Views.DeploymentsShow({ model: deployment,
collection: deployment.instances });
--
1.7.6
12 years, 8 months
pending patches
by Jan Provazník
Hi,
2 of my patches waiting for a review are quite important:
"provider account fix" (08/16/2011)
- this patch fixes XML format of account credentials which is passed to
imagefactory when building/pushing an image. Build/push for ec2 image
failed for me w/o this patch (if is able to build&push ec2 image, let me
know please).
"[PATCH conductor] Rack-restful_submit hotfix" (08/22/2011)
- restful_submit doesn't work properly w/o this when installed from RPM,
it's used mainly for deleting records, but also for selecting a provider
type when adding a provider account
If you have some time, please take look at it.
Thanks, Jan
12 years, 8 months
[PATCH 0/1 conductor] Update RPM spec
by Matt Wagner
Oops, I neglected to update the RPM spec to match my changes to Conductor views, and it just blew up for eggs. This should get it back to where it should have been.
-- Matt
12 years, 8 months
[PATCH conductor] CSV export for instances
by Tomas Hrcka
---
src/Gemfile | 1 +
src/app/controllers/instances_controller.rb | 9 ++++++++-
src/app/models/instance.rb | 26 ++++++++++++++++++++++++++
src/app/views/instances/_list.haml | 1 +
src/config/routes.rb | 1 +
src/spec/models/instance_spec.rb | 17 +++++++++++++++++
6 files changed, 54 insertions(+), 1 deletions(-)
diff --git a/src/Gemfile b/src/Gemfile
index ce11e9d..05d3b7c 100644
--- a/src/Gemfile
+++ b/src/Gemfile
@@ -21,6 +21,7 @@ gem 'pg'
gem 'thin'
gem 'json'
gem 'railties'
+gem 'fastercsv'
group :development, :test do
#gem 'rspec-rails'
#gem 'factory_girl_rails'
diff --git a/src/app/controllers/instances_controller.rb b/src/app/controllers/instances_controller.rb
index bde8bb3..09046a1 100644
--- a/src/app/controllers/instances_controller.rb
+++ b/src/app/controllers/instances_controller.rb
@@ -1,7 +1,7 @@
class InstancesController < ApplicationController
before_filter :require_user
before_filter :load_instance, :only => [:show, :key, :edit, :update]
- before_filter :set_view_vars, :only => [:show, :index]
+ before_filter :set_view_vars, :only => [:show, :index, :export_events]
def index
@params = params
@@ -12,6 +12,7 @@ class InstancesController < ApplicationController
format.html
format.js { render :partial => 'list' }
format.json { render :json => @instances }
+
end
end
@@ -148,6 +149,12 @@ class InstancesController < ApplicationController
end
end
+ def export_events
+ send_data(Instance.csv_export(load_instances),
+ :type => 'text/csv; charset=utf-8; header=present',
+ :filename => "export.csv")
+ end
+
private
def load_instance
diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
index aee4750..85454cf 100644
--- a/src/app/models/instance.rb
+++ b/src/app/models/instance.rb
@@ -341,6 +341,32 @@ class Instance < ActiveRecord::Base
read_attribute(:public_addresses)
end
+ def create_auth_key
+ raise "instance provider_account is not set" unless self.provider_account
+ client = self.provider_account.connect
+ return nil unless client && client.feature?(:instances, :authentication_key)
+ kname = "#{self.name}_#{Time.now.to_i}_key_#{self.object_id}".gsub(/[^a-zA-Z0-9\.\-]/, '_')
+ if key = client.create_key(:name => kname)
+ self.update_attribute(:instance_key, InstanceKey.create!(:pem => key.pem.first, :name => key.id, :instance_key_owner => self))
+ end
+ end
+
+ def self.csv_export(instances)
+ csv_string = FasterCSV.generate(:col_sep => ";", :row_sep => "\r\n") do |csv|
+ event_attributes = Event.new.attributes.keys.reject {|key| key if key == "created_at" || key == "updated_at"}
+
+ csv << event_attributes.map {|event| event.capitalize }
+
+ events = instances.map{|i| i.events}.flatten!
+ unless events.nil?
+ events.each do |event|
+ csv << event_attributes.map {|event_attribute| event[event_attribute] }
+ end
+ end
+ end
+ csv_string
+ end
+
scope :with_hardware_profile, lambda {
{:include => :hardware_profile}
}
diff --git a/src/app/views/instances/_list.haml b/src/app/views/instances/_list.haml
index f9545e4..316ad14 100644
--- a/src/app/views/instances/_list.haml
+++ b/src/app/views/instances/_list.haml
@@ -1,4 +1,5 @@
- content_for :form_header do
+ %li= link_to "Export events", export_events_instances_path, :class => 'button'
%li= restful_submit_tag 'Stop Selected Instances', 'stop', multi_stop_instances_path, 'GET', :class => 'button', :id => 'stop_selected_instances'
= hidden_field_tag 'backlink', request.url
%li
diff --git a/src/config/routes.rb b/src/config/routes.rb
index 67262ae..3def92a 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -95,6 +95,7 @@ Conductor::Application.routes.draw do
get 'start'
get 'multi_stop'
get 'remove_failed'
+ get 'export_events'
end
member do
get 'key'
diff --git a/src/spec/models/instance_spec.rb b/src/spec/models/instance_spec.rb
index 13ccafe..da0f849 100644
--- a/src/spec/models/instance_spec.rb
+++ b/src/spec/models/instance_spec.rb
@@ -194,4 +194,21 @@ describe Instance do
@pool.pool_family.provider_accounts = [FactoryGirl.create(:mock_provider_account, :label => 'testaccount', :provider => provider)]
@instance.matches.first.should_not be_empty
end
+
+ it "should return csv header string for export" do
+ reader = CSV::Reader.create(Instance.csv_export([FactoryGirl.create(:instance)]))
+ header = reader.shift
+ ['Status_code','Event_time','Summary','Source_type','Description','Source_id'].each do |attribute|
+ header[0].split(';').include?(attribute).should be_true
+ end
+ end
+
+ it "should return csv string for export" do
+ instance = FactoryGirl.create(:instance)
+ export_string = Instance.csv_export([instance]).gsub(/\s+/, "")
+
+ export_string.include?(instance.id.to_s).should be_true
+ export_string.include?("Instance").should be_true
+ export_string.include?("created").should be_true
+ end
end
--
1.7.6
12 years, 8 months
[PATCH conductor 0/5] Catalogs -- rev. 3
by Matt Wagner
This is an update of catalogs, with Jan's feedback incorporated.
I did not add a migration for legacy users, so you'll need to re-do your database before adding CatalogEntries, and existing SuggestedDeployables will stop working. I started to add a migration to "do the right thing," but I don't think it will work. The problem is that a CatalogEntry now needs to belong to a Catalog, which needs to belong to a Pool. To do this programmatically, we'd have to detect if there were SuggestedDeployables (which become CatalogEntries), create a Catalog, and then arbitrarily tie that Catalog to some pool. (Plus, you can't 'down' the migration, since you'd end up deleting data.) It ended up feeling really messy and arbitrary. If there are strong objections I can add it, but I'm not sure it's advisable.
-- Matt
12 years, 8 months
ANNOUNCE: oz0.6.0 release
by Chris Lalancette
All,
I'm pleased to announce release 0.6.0 of Oz. Oz is a program for doing
automated installation of guest operating systems with limited input from
the user.
Release 0.6.0 is a bugfix and feature release for Oz. Some of the
highlights between Oz 0.5.0 and 0.6.0 are:
- The ability to specify the destination for the ICICLE output from oz-install
and oz-generate-icicle
- pydoc class documentation for all internal Oz classes
- Automatic detection of KVM or QEMU at runtime (this allows oz to be used
within virtual machines, although with a large performance hit)
- Less scary warning messages in the debug output
- Printing of the screenshot path when a build fails
- Ability to run multiple Oz installs of the same OS at the same time
- Support for OEL and ScientificLinux
- Support for RHEL-5.7
- Support for CentOS 6
- Support for OpenSUSE arbitrary file injection and command execution
- Ability to make the TDL (template) parsing enforce a root password
- Rejection of localhost URLs for repositories (since they must be reachable
from the guest operating system, localhost URLs make no sense)
Fedora-14, Fedora-15, and RHEL-6 packages are available for this release. Note
that to install the RHEL-6 packages, you must be running RHEL-6.1 or later.
Instructions on how to get and use Oz are available at
http://aeolusproject.org/oz.html
If you have any questions or comments about Oz, please feel free to contact
aeolus-devel(a)lists.fedorahosted.org or me (clalance(a)redhat.com) directly.
Thanks to everyone who contributed to this release through bug reports,
patches, and suggestions for improvement.
--
Chris Lalancette
12 years, 8 months
[PATCH conductor] Additional fix for the Backbone hash URL redirect
by Tomas Sedovic
From: Tomas Sedovic <tsedovic(a)redhat.com>
Occasionally, Backbone would still redirect to the hash-based URLs. This
should fix it once and for all.
---
src/app/views/layouts/application.haml | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/app/views/layouts/application.haml b/src/app/views/layouts/application.haml
index e7a8ced..386c385 100644
--- a/src/app/views/layouts/application.haml
+++ b/src/app/views/layouts/application.haml
@@ -20,6 +20,7 @@
// when the browser doesn't support the HTML5 History API.
window.history || (window.history = {});
window.history.pushState || (window.history.pushState = function(){});
+ window.history.replaceState || (window.history.replaceState = function(){});
= javascript_include_tag "jquery-1.6.1.min.js"
= javascript_include_tag "jquery.ui-1.8.1/jquery-ui-1.8.1.custom.min.js"
--
1.7.6
12 years, 8 months
Aeolus 0.3.0 tests (continue)
by michel.gauthier@bull.net
Hi Justin and Michal,
We have downloaded the example template fedora14 x86_64 and then build the
corresponding image for ec2 using the command :
aeolus-image build --target ec2 --template fedora_14_x86_64.tpl
The result was :
Target Image: 7756b621-4543-42f7-bcf1-e9326f5b5f20
Image: 864dad40-cf9b-44c2-ae84-962d64bb8996
Build: ad4b8caa-f3d4-4f42-8fd4-968b67e3c4e5
Status: COMPLETED
Percent Complete: 100
The status COMPLETED and the percent complete value of 100 mean that the
operation is entirely completed, in a synchronous way. Is it right?
aeolus-image list --images
IMAGE ID LASTEST PUSHED BUILD NAME
TARGET OS OS VERSION ARCH DESCR
IPTION
864dad40-cf9b-44c2-ae84-962d64bb8996 Fedora
14 x86_64 with updates ec2 Fedora 14 x86_64
Fedor a 14 and all of its released updates
Question : Is it possible to see/display this image using the Conductor
web console?
Next step, pushing of the image using the command :
aeolus-image push --provider ec2-us-east-1 --id
864dad40-cf9b-44c2-ae84-962d64bb8996
gives the following output :
Provider Image: c3a4ca98-4c20-438d-af4c-983c2fd17221
Image: 864dad40-cf9b-44c2-ae84-962d64bb8996
Build: ad4b8caa-f3d4-4f42-8fd4-968b67e3c4e5
Status: New
Percent Complete: 0
The status New and the percent complete value of 0 mean that the operation
is not entirely completed, and is processed in an asynchronous way. Is it
right?
Question : In this case, how can we track the progression of the operation
(command line, Conductor web console, Amazon console,...)?
A few hours after the pushing, the aeolus-image list --images command
gives the same result :
IMAGE ID LASTEST PUSHED BUILD NAME
TARGET OS OS VERSION ARCH DESCRIPTION
864dad40-cf9b-44c2-ae84-962d64bb8996 Fedora
14 x86_64 with updates ec2 Fedora 14 x86_64
Fedora 14 and all of its released updates
The LASTEST PUSHED BUILD is not set!
Is the operation really completed or has it aborted? (nothing in logs)
Thank you for help,
Michel
12 years, 8 months